Friday, March 23, 2012

Reset identity column

A number of records were written to a table with an identity column that has an identity seed.
These records had to be deleted, and I would like to begin the numeric sequence at a point as if the records had never been added. E.g., before the incorrect records were added, the value of this column was 2500. Two hundred records were added, then removed. I would like the next value to be 2501, however new records are starting at 2701, after the incorrect records were removed.
Is DBCC CHECKIDENT the only way to correct this? Do I have to reseed the value, or is there another way?
Thanks for any assistance on this.Never mind, I have answered my own question: dbcc checkident is the solution...
Thanks
"TomT" wrote:
> A number of records were written to a table with an identity column that has an identity seed.
> These records had to be deleted, and I would like to begin the numeric sequence at a point as if the records had never been added. E.g., before the incorrect records were added, the value of this column was 2500. Two hundred records were added, then removed. I would like the next value to be 2501, however new records are starting at 2701, after the incorrect records were removed.
> Is DBCC CHECKIDENT the only way to correct this? Do I have to reseed the value, or is there another way?
> Thanks for any assistance on this.

No comments:

Post a Comment