Saturday, October 30, 2010

SQL Server - Insert in identity column for a table

Sometimes there is a need to insert data into a table that has identity column. Example when you would like to restore a table from a backup including the same IDs so integrity is maintained. Here is simple script

--set identity insert on
set identity_insert <table_name> on

--set identity insert off
set identity_insert <table_name> off

No comments:

Post a Comment