0

I have a problem restoring a table. I wanted to restore data by copying data from the backup to the table. The problem is, the PK of the table has the Identity-Property set. So when I inserted the lost rows they got new IDs. I created a new table without identity and put the data in there. Now I want to turn on Identity on the PK column, which doesn't work.

Any what I can do or if this is possible at all?

roalz
  • 2,699
  • 3
  • 25
  • 42
FNR
  • 489
  • 1
  • 4
  • 17

3 Answers3

0

You cannot add IDENTITY property to existing column. Either you insert in existing table with IDENTITY column with IDENTITY_INSERT ON' option or you create a newIDENTITY` column in the new table.

This post might help you

Community
  • 1
  • 1
Venu
  • 455
  • 2
  • 7
-1

This will solve your problem [https://stackoverflow.com/a/1049305/6652909]

Community
  • 1
  • 1
Mohammad
  • 132
  • 5
-1

If you have backup of table then TRUNCATE your table then set primary key then make it auto increment in table and then copy your table and make sure your data of table is entered properly, it worked for me may be it will helpful to you also.

Sweta Parmar
  • 269
  • 1
  • 11