How to reset Identity column in SQL Server?
Recently, a programmer in my team, Amichai Sichel, had found a way to reset identity column in SQL Server DataBase. The reason he had to reset it was for testing and because of relations between tables he could not use TRUNCATE TABLE.
Assuming you want to clear your data, you first need to clean it with DELETE FROM [TableName], then you can RESEED it to any number you want, you need to RESEED it to the value before incrementing (if the column is specified a IDENTITY (1,1) which means its incremental is 1, you need to set it to the value you want minus 1)
DBCC CHECKIDENT('[TableName]', RESEED, 0) -- Will reseed it to 0 and the next identity will be 1 (assuming IDENTITY(1,1))
DBCC CHECKIDENT('[TableName]', NORESEED) -- Will not reseed the value and will return the maximum column value
for more information: http://technet.microsoft.com/en-us/library/ms176057.aspx
Thanks to Amichai Sichel