Monday, January 24, 2011

How to Reset Identity column in SqlServer

In this post i explained how to reset the identity column in a table.
we have two methods to reset the identity column 
1) Using Truncate Method.
2) Using DBCC (database consistency checker)
But TRUNCATE TABLE cannot be used when a foreign key references the table to be truncated where as DBCC can.

here is the Query using DBCC

In Above query '0' is the reset idetity seed number,you can give any number whatever you want like 20,30 etc..
Here is the Query Using Truncate 
truncate table TableName

No comments:

Post a Comment