Friday, May 8, 2009

Resetting an Identity Seed Using Stored Procedure

Ferlin found this; I thought it was interesting and potentially useful. Apparently in MSSQL 2005, you can delete all the rows in a database with an identity column, but that identity seed does not reset once you enter new records--it simply resumes with the last record before the delete. This handy little stored procedure will allow you to reset the identity seed of a table:

DBCC CHECKIDENT(@TableName, RESEED, 0)

No comments:

Post a Comment