Thursday, July 30, 2009

Resetting Table Identity

TRUNCATE TABLE can be used to reset the identity counter,but it can 't be used on a table referenced by a foreign key when you delete all records by using DELETE command and reset the table by using the following command.

Syntax:

DBCC CHECKIDENT ('table_name', RESEED, new_reseed_value)

 Tablename   : Table name that you want to reset identity
 RESEED       : that is keyword
 New Reseed Value : give new reseeding  value

Example:
DBCC CHECKIDENT (emp,reseed,0)

No comments:

Post a Comment