Re-insert records with IDENTITY Insert in SQL Server
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.
精彩评论