Resetting the IDENTITY counter in SQL Server T-SQL

You’ve been there before.  You are busily testing your import routines and running up the Identity column in your main import table.  Before you know it the value is in the multi-millions and you just want to reset it back to 1. 

The way to accomplish this is to use the DBCC CHECKIDENT command.

For example:

DBCC CHECKIDENT (SalesForce, reseed, 0)

This assumes your table is called SalesForce and you want to start the numbering at 1.  If you wanted to start the number at 2000 you can substitute 0 with 1999.  There has been some discussion that has said if the table never had records added to it the reseed value itself will be used instead of the reseed + 1 value.  You should not need to use this statement for a “new” table.

Credit for this post is given to Pinal Dave over at http://sqlauthority.com/.  The specific post this I am referring to is the one at this page.