Thursday, August 13, 2009

SQL Server -Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table ' Table' when IDENTITY_INSERT is set to OFF.


Error Message:
Msg 544, Level 16, State 1, Line 1
Cannot insert explicit value for identity column in table  ' Table' when IDENTITY_INSERT is set to OFF.

    This error occurs when you are trying to insert value into a column which has IDENTITY property.To fix the error by setting IDENTITY_INSERT to ON.

Fix:
SET IDENTITY_INSERT [database_name].[schema_name].[tablename]  ON

INSERT INTO [database_name].[schema_name].[tablename] (ID,Name)   VALUES (11,'Viji')

SET IDENTITY_INSERT  
[database_name].[schema_name].[tablename] OFF

No comments:

Post a Comment