Thursday, July 5, 2007

SQL Server : Command to Reset Identity Column of a table

Many times we need to reset the Identity column of a table in Sql Server, we can do this by going to Sql Server Enterprise Manager and Reseting the Identity, Recently I came across a command that does the same..

Syntax:-
DBCC CHECKIDENT(strTableName, RESEED, intSeed)

where strTableName is the Name of the table for identity reset, intSeed is the Seed from which Identity should start now.


e.g. DBCC CHECKIDENT('tblUserDetails', RESEED, 10)

will reseed the Identity column in tblUserDetails table, now the new entry will have its Identity column value as 11.

-------------------------------------------------------------
Irfan Sheikh

No comments: