“Set identity_insert on” errors for more than one table

I was trying to remove the Identity inserts for 4 tables all at once but I keeping getting errors like Cannot remove the Identity insert on table 2 as the table1 already has identity insert on.

So after digging into the MSDN I was surprised to see the following lines

“At any time, only one table in a session can have the IDENTITY_INSERT property set to ON. If a table already has this property set to ON, and a SET IDENTITY_INSERT ON statement is issued for another table, Microsoft® SQL Server™ returns an error message that states SET IDENTITY_INSERT is already ON and reports the table it is set ON for.”

Leave a Reply