Thursday, October 29, 2009

Turning off SQL Identity when required

Occasionally, we may want to insert values manually into a column which is set as Identity column in SQL Server.

As we can think of, we need to do this at a table level before inserting such values. Here is the command we could use to turn the identity off temporarily, insert records and then turn the identity back on the table column.

SET IDENTITY_INSERT ON

INSERT goes here

SET IDENTITY_INSERT OFF

For more information, follow this link

No comments:

Post a Comment