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

后端 未结 2 1246
执念已碎
执念已碎 2020-12-17 09:01

I created a trigger that performs a check and automatically populates data into 2 tables. Only what happens the following error :

IDENTITY_INSERT is already         


        
2条回答
  •  甜味超标
    2020-12-17 09:08

    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.

提交回复
热议问题