Search This Blog

Thursday, March 22, 2012

IDENTITY_INSERT

If you want to insert a specific value into a identity column of a sql server table then here is how you can do it.

SET IDENTITY_INSERT ON

And then insert the identity value into the table. If a table already has this property set to ON in the same session then SQL will throw out the error indicating which table is it set.

After inserting the value set it OFF by executing

SET IDENTITY_INSERT OFF

No comments:

Post a Comment