DBCC CHECKIDENT – manually reset a new current identity value for the identity column

Checks the current identity value for the specified table and, if it is needed, changes the identity value by using DBCC CHECKIDENT

DBCC CHECKIDENT can reset (i.e. reseed) the identity value of the table for the identity column.

For example, Your Table has 5 rows with 5 as last identity. If we want next record to have identity as 15 we need to run following SQL query.

DBCC CHECKIDENT (<YourTableName>, reseed, 14)

If table has to start with an identity of 1 with the next insert then table should be reseeded with the identity to 0.

There are two conditions where it will not work:

  • The current identity value is larger than the maximum value in the table.
  • All rows are deleted from the table.

Reference Link:

Happy Coding 🙂