How to Reset identity column in SQL Server

If you are using an identity column in a table, Using DBCC CHECKIDENT, we can reseed (reset) the identity value of the table.
If there are 50 rows existing in your table, If we want next record to have identity as 2000, we need to run following script.

DBCC CHECKIDENT (yourtable, reseed, 1999)

The next record will be inserted on 2000th position.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s