Wednesday, January 13, 2016

Reset Auto Increment ID in SQL Server

Been asked this way too many times and I google it every time. So during development, when you need to reset the ID for your auto increment column:

DBCC CHECKIDENT (mytable, RESEED, 0)

This command reseeds "mytable" to start at 1. Be careful that we don't have records higher than the seed value you are setting. You'll break the table.

Also:

  • http://stackoverflow.com/questions/510121/reset-autoincrement-in-sql-server-after-delete