Resetting the Primary Key of a Table

This quick tip will show how to reset the primary key values for a table in SQL Server:

DBCC CHECKIDENT ([Table], RESEED, [NewCurrentValue])

Where [Table] is the table name and [NewCurrentValue] is the new current value of the id. This would ideally be set to 0, so that the next value (when a row is inserted) will be 1.

About OJ

OJ Raqueño is a senior software developer specializing in business web applications. He has a passion for helping businesses grow through the use of software built with the best engineering practices.