0
I created a table in the BD with the following code
CREATE TABLE documentosDefesa
(
id_documentos_defesa int NOT NULL,
id_reclamatoria int NOT NULL,
funcao nvarchar(50) NULL
);
And now when I try to make the following insertion,:
INSERT INTO [RDO].[dbo].[documentosDefesa] (id_reclamatoria, funcao) VALUES (177,'Pedreiro')
in SQL SERVER MANAGEMENT it displays the following warning:
Cannot insert NULL value in column 'id_documents_defense', table 'RDO.dbo.documentsDefesa'; column does not allow nulls. INSERT failure.
I don’t understand why I made a mistake, because it’s not the first time I’ve created a table and I do it!
That field is
identity
?– rray
The camp was created as
int NOT NULL
so it can’t be null. I think it should be declared asidentity
and notint
– ramaral
No... How should I proceed then? I change the field to int Identity?
– GustavoSevero
But the system itself is responsible for putting value in this field, right?
– GustavoSevero
Yes, if it is
identity
– ramaral
Right. So, just change the field? Put Identity?
– GustavoSevero
It must be declared so:
id_documentos_defesa int IDENTITY(1,1) PRIMARY KEY,
– ramaral
Thanks guys, it worked out
– GustavoSevero