Tuesday, November 26, 2013

Reset Identity Column Value to 1 in SQL Database


To reset identity column value and start value from “1” during insert new records we need to write query to reset identity column value. Check below Query


DBCC CHECKIDENT (Table_Name, RESEED, New_Reseed_Value)

Table_Name is name of your identity column table

RESEED specifies that the current identity value should be changed.

New_Reseed_Value is the new value to use as the current value of the identity column.   
  

EX: DBCC CHECKIDENT ('UserDetails', RESEED, 0)

Once we run the above query it will reset the identity column in UserDetails table and starts identity column value from “1”