开发者

Re-insert records with IDENTITY Insert in SQL Server

开发者 https://www.devze.com 2023-03-27 15:21 出处:网络
Some records in a table (with no primary key) were deleted. I need to re-insert these records. One 开发者_如何学JAVAof my column is an IDENTITY column,

Some records in a table (with no primary key) were deleted. I need to re-insert these records. One 开发者_如何学JAVAof my column is an IDENTITY column,

What should be my approach on a live database? Should I do IDENTITY_INSERT ON/OFF or is there a better way?


If you have to insert records whose identity column has to have a specific value (to restore eventual past references), then i would say yes, even if this is risky due to possible duplicates.

Otherwise you insert them again with the new IDENTITY values.

0

精彩评论

暂无评论...
验证码 换一张
取 消