Monday, July 23, 2012

How to Turn on IDENTITY_INSERT in SQL Server 2008?

Via SQL as per MSDN
SET IDENTITY_INSERT sometableWithIdentity ON
INSERT sometableWithIdentity (IdentityColumn, col2, col3, ...)
VALUES (AnIdentityValue, col2value, col3value, ...)
SET IDENTITY_INSERT sometableWithIdentity OFF
The complete error message tells you exactly what is wrong...
Cannot insert explicit value for identity column in table 'sometableWithIdentity' when IDENTITY_INSERT is set to OFF.
 http://stackoverflow.com/questions/7063501/how-to-turn-on-identity-insert-in-sql-server-2008

No comments:

Post a Comment