truncatecommand. This will
deletedata from table and also reset the identity column value to
truncate table [table_name] -- for example truncate table product
truncate command fails to delete the data if there is a relationship given to the table and the identity column is not reset.
The other way is...
In this case, first you need to
delete data from the
child and the
After deleting data, fire this command and it will reset your identity column to
DBCC CHECKIDENT('[table_name]', RESEED, [new_reseed_value]) DBCC CHECKIDENT('product', RESEED, 0)
DBCC CHECKIDENT can reseed (reset) the identity value of the table. For example, YourTable has 25 rows with 25 as last identity. If we want next record to have identity as 35 we need to run following T SQL script in Query Analyzer.
DBCC CHECKIDENT (yourtable, reseed, 34)