On Transact SQL language the Msg 515 Level 16 - Cannot insert the value NULL into column means that the column does not allow nulls and the insert fails.
Msg 515 Level 16 Example:
We have the table teachers:
USE model;
GO
CREATE TABLE teachers(
ID INT IDENTITY NOT NULL PRIMARY KEY,
Name VARCHAR(250) NOT NULL,
Department VARCHAR(250) NOT NULL);
GO
Invalid insert:
USE model;
GO
INSERT INTO teachers(id, name, department)
VALUES ('Olivia Wilson', null), ('Ethan Davis', null);
GO
Message |
---|
Msg 515, Level 16, State 2, Line 1 |
Cannot insert the value NULL into column 'Department', table 'model.dbo.teachers'; column does not allow nulls. INSERT fails. The statement has been terminated. |
Correct insert:
USE model;
GO
INSERT INTO teachers(name, department)
VALUES ('Olivia Wilson', 'Anthropology'), ('Ethan Davis', 'Biology');
GO
Message |
---|
(2 row(s) affected) |
Other error messages:
- Conversion failed when converting date and/or time from character string
- Is not a defined system type
- Conversion failed when converting the varchar value
- Unknown object type used in a CREATE, DROP, or ALTER statement
- Cannot insert explicit value for identity column in table
- The INSERT statement conflicted with the FOREIGN KEY constraint
- The DELETE statement conflicted with the REFERENCE constraint