How to reseed the identity value of a table?
Posted on | July 28, 2008 | No Comments
I was working on a project and there was a lookup table in that which needed to be populated and its identity values needed to strictly match with the database at my client’s end. At first when I tried to insert data from another table it turned in to an error, the rows didnt get inserted but the identity value increased due to a lost transaction. So I ran this script in order to reset the indentity value in that table. Please note that to start the identity values from 1 you need to reseed it to zero. The other important thing is that you should delete the rows with a higher identity value because it will not skip that, but it will try to overwrite it which would result in an error.
dbcc checkident (mytableName, reseed, 0)
Comments
Leave a Reply



