Sunday, June 15, 2008

Reset Identity Column Value

DBCC CHECKIDENT statement can reset/reseed the identity column value.

e.g to set the current identity value in "MyTable" to 500 statement will be

DBCC CHECKIDENT (MyTable, RESEED, 500)

Following command can also be used to reset the identity column value if all the records in table can be deleted.

TRUNCATE TABLE MyTable