IDENTITY_INSERT is already ON for table ‘X’. Cannot perform SET operation for table ‘Y’

I had a similar problem but it did not involve table triggers. I was running a script that refreshes data for multiple tables and I hit a foreign key reference error.

According to MSDN:

At any time, only one table in a session can have the IDENTITY_INSERT
property set to ON.

To resolve this, I ran SET IDENTITY_INSERT [dbo].[table_name] OFF for each table I was trying to insert into. Then I was able to refresh my tables again after I corrected the reference error.

Edit: I should also mention that you can just disconnect and then reconnect to reset your session.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)