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.
Written by Pure Krome
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Sql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#