Last Updated: February 25, 2016
·
541
· purekrome

Resetting a Sql Server Identity column (manually)

Sometimes it's too much work to truncate a table (because of foriegn keys, etc).

-- Delete all the records in the table
DELETE [dbo].[Foo]

-- Reset the Identity field.
DBCC CHECKIDENT('Foo', RESEED, 0)

Next record inserted will get the Id: 1.