Reset an identity column of a table in SQL Server
I use this to clean up my tables after completing development of a data-load script.
The reason... I keep deleting data from the table and re-running the script over and over again, and of course, the identity keeps getting bigger and bigger. At the end, the id of the first entry in the table has some ridiculous number and honestly...
I just can't have it.
Enjoy!
Syntax
DBCC CHECKIDENT (<table>, RESEED, <value>) |
Option | Description |
---|---|
table | The name of the table to be reset. |
value | The new value to be used. |
Example
DBCC CHECKIDENT ('Employee', RESEED, 1) |