Error Message:
Msg 545, Level 16, State 1, Line 4
Explicit value must be specified for identity column in table ‘%.*ls’ either when IDENTITY_INSERT is set to ON or when a replication user is inserting into a NOT FOR REPLICATION identity column.
Severity level:
16.
Description:
This error message appears when you try to insert into a table with an IDENTITY column, but do not provide a value for that column, while IDENTITY_INSERT is set to ON for that table.
Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.
Resolution:
Error of the Severity level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be run this way. You must provide a value for the IDENTITY column when IDENTITY_INSERT is set to ON.
Versions:
All versions of SQL Server.
Example(s):
IF OBJECT_ID (‘dbo.t’) IS NOT NULL
DROP TABLE dbo.t;
GO
CREATE TABLE dbo.t
(
c1 int IDENTITY
)
GO
SET IDENTITY_INSERT dbo.t ON;
INSERT INTO dbo.t DEFAULT VALUES;
SET IDENTITY_INSERT dbo.t OFF;
Remarks:
In the above example we try to insert a row into the table dbo.t. Because we do not provide a value for c1 while IDENTITY_INSERT is set to ON, the error is raised.
]]>