My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://ashokbasnet.com.np
and update your bookmarks.

Tuesday, June 26, 2012

Reset indentity value of Auto increment Key to 0 in SQL server 2008

I have been searching for resetting the Auto increment value of ID Column in MSSQL Server 2008 and finally solved the problem. You can simply do the following in SQL.

The following line resets the Identity value for the ‘MyTable’ table to 0 so that the next record added starts at

DBCC CHECKIDENT(‘MyTable’, RESEED, 0)

The truncate command can also does the trick but its not applicable if there are some foreign key constraints.

For more information on DBCC CHECKINDENT you can refer MSDN.http://msdn.microsoft.com/en-us/library/ms176057.aspx

0 comments :

Post a Comment