How To Reset Identity Column Value in SQL Server

Check Identity Value

DBCC CHECKIDENT (tablename, NORESEED)

Set Identity Value

DBCC CHECKIDENT (tablename, RESEED, identvalue)

This means that the number you input in place of 'identvalue' should be the CURRENT last index. The next value will be identvalue + 1. If you enter 999 then the next record inserted will have a value of 1000.

To reset a table:

DBCC CHECKIDENT (tablename, RESEED, 0)

Sources

howto/reset_identity_column_value_in_sql_server.txt · Last modified: 2011/12/19 21:15 by smark
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0