Tuesday, October 12, 2010

mssql: insert values into table with identity column

You should use IDENTITY_INSERT command like this:
SET IDENTITY_INSERT YourTableName ON

INSERT INTO YourTableName (YourIdentityColumn, ValueCoulmn)
VALUES (1, 'Value')

SET IDENTITY_INSERT YourTableName OFF