SQL Server FUN – Identity insert

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

 

Leave a Reply

Your email address will not be published. Required fields are marked *