Re-seeding an identity column in SQL using DBCC CHECKIDENT

Here’s a handy bit of SQL that i’ve been using to reset the seed of an identity column for a table. I have often needed to do this when i’ve cleaned out a table, but have needed to start the identity entry back at 0 rather than it’s current seed value

DBCC CHECKIDENT (<table name>, RESEED, -1)

Simply fill in the name of the table and execute it. This will reseed the identity to -1 meaning that when you next enter a new row it will start at 0.

Lastly, make sure you have the GO command between calls to DBCC or it won’t work 🙁

Tagged . Bookmark the permalink.

Leave a Reply