Friday, July 9, 2010

Set/Reset identity value on SQL Server 2005

There are times we would like to set identity column to a specific value on SQL Server. In the most common case, we would like to reset it to start from the value 1.

This is how it is done:

DBCC CHECKIDENT('some_table', RESEED, 0)


Note that the last parameter is the value for which the identity column is set. If we set it to: 0, the next value of the inserted row will be: 1.

1 comment: