Reset Identity column in SQL Server – RESEED Table Identity Value

Table with Identity column will not reset even if we delete all records and will not gets a fresh start at primary key 1. To reset the identity column, use this :

DBCC CHECKIDENT (tablename, reseed, 0)

Yes we have to use ‘0’ if we want the identity column to start from 1. So next time, if we insert a record, the identity column will be 1.

But if we already have 136 records but we want the identity column to start from 201 rather than 137, we have to use this:

DBCC CHECKIDENT (tablename, reseed, 200)

Remember, always 1 less then the value we want to start the identity value.

 

Advertisements
By simplemsexchange Posted in SQL 2008

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