How to reseed identity column using TSQL

If you need to reseed identity column, use DBCC CHECKIDENT command.

DBCC CHECKIDENT (table_name, RESEED, starting_value)

Thing to note here is that starting value should be one less than the next value you want to see in your identity column. So if you are reseeding the table and want to see 1 in the identity column when next record is inserted, put 0 as starting value.

You can read more about DBCC CHECKIDENT on MSDN.

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