Reputation: 243
I need to merge some data (include identity column) from other server to my server without interrupting my service running. I export the data from the other server and insert into to my server like this:
SET IDENTITY_INSERT tbl_content ON
... insert command ...
SET IDENTITY_INSERT tbl_content OFF
However, if I set the IDENTITY_INSERT
on, other applications inserting data into the database without identity column will get an error
Explicit value must be specified for identity column in table '....' either when IDENTITY_INSERT is set to ON
How can I insert identity column without interrupting other applications?
Upvotes: 0
Views: 128
Reputation: 5209
Why not use SqlTransaction
when performing the bulk insert. Yes your table will be locked for some time but atleast you'll guarantee data integrity.
Upvotes: 2