Thursday, October 23, 2008

Resetting the identity field in SQL Server

Resetting identity field in SQL Server can be achieved by following command

DBCC CHECKIDENT('table name', RESEED, number_you_need_to_reset )

For eg:
If your customer table is empty and wanted to reset the identity field value to 1 then use the following comand

DBCC CHECKIDENT('customer', RESEED, 0 )

So next time when you add a record the identity field value will be 1.

Add To Google BookmarksStumble ThisFav This With TechnoratiAdd To Del.icio.usDigg ThisAdd To RedditTwit ThisAdd To FacebookAdd To Yahoo