MS SQL Server – Resetting/Changing the identity[auto-increment number] column value of a table

Test Environment: MS Server 2008

DBCC CHECKIDENT checks the current identity value for the specified table and, if it is needed, changes the identity value. You can also use DBCC CHECKIDENT to manually set a new current identity value for the identity column

Table to alter:

In the above code ‘DocumentType_ID’ column has declared as Identity, having auto increment value by 1 starting with 0. This means the first row inserted will have ‘DocumentType_ID’ value of 1. then 2,3,so on..

In future if we want to reset this value, for what so ever reason, we can use T-SQL:

This code will reset table Identity back to 0.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">