Register now or log in to join your professional community.
If we have TableA with ideantity(1,1) -Generate a new script for TableA without identity(1,1) to a column
-Rename the table name to TableB . Run the script
-Insert the values from TableA to TableB. (Now the data in the TableA and TableB are same)
-Insert the deleted keys in TableB. (So we now have deleted keys)
-Go to TableB properties and set Identity(1,1) to the column
-Drop table TableA-Rename TableB to TableASo we successfully inserted deleted keys where identity(1,1) in a column without disabling identity contraint.
set IDENTITY_INSERT ON for insert the records into the table
set IDENTITY_INSERT ON before insert operation.
Using Reseed command and Insert the records
Tried to think of how i would do this but yeah, Mosam Vadiekar summed it up perfectly.
we can create a triger for the table. if we delete the table data it will keep in the backup table. so we can restore the lost data any time. it is a simple solution but we have many other ways to restore the deleted datas.
The answer is to use RESEED keyword and insert the missing record
Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.