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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.