Sunday, February 19, 2012

Giving Value for Identity column while inserting

I have a table with an Identity column. The latest Identity value is 1298. A row with Identity 324 was deleted by mistake and I need to insert it now. But if I insert it now it will have Identity value of 1299. I tried giving the value 324 for the Identity column in the Insert statement but it throws error. How can I insert this row with the same Identity value as before??

Quote:

Originally Posted by sajithamol

I have a table with an Identity column. The latest Identity value is 1298. A row with Identity 324 was deleted by mistake and I need to insert it now. But if I insert it now it will have Identity value of 1299. I tried giving the value 324 for the Identity column in the Insert statement but it throws error. How can I insert this row with the same Identity value as before??


Are you not able to insert using a plain insert statement on query analyser?|||You can do this by
SET IDENTITY_INSERT [table_name] ON
and then turn it off

No comments:

Post a Comment