Monday, December 17, 2012

How to remove all data from table and reseed identity column to initial value?

Problem: How to remove all data from table and reseed identity column to initial value?

 Solution: For this purpose best solution is to use truncate sql command when you want to delete all data and reset identity column value to initial value.
Ex. TRUNCATE TABLE tableName

Somebody uses the following command which results same output:

DELETE FROM tableName
DBCC CHECKIDENT (tableName,RESEED, 0)




1 comment:

  1. http://getproductprice.com/Ads-can-we-reset-identity-values-at-a-new-seed-in-sql.aspx

    ReplyDelete