------------------------
Reset the Identity Increment
Hello:
I have a table with a bigint type column (field) that has an identity seed
of 1 and an identity increment of 1. The column is the primary key for the
table.
After I backup and clean out the database (delete all of the data in the DB)
I need to have the column with the identiy seed/increment value reset to 1
automatically. (start counting at 1 again). How does one do that, because
as it is now, the DB keeps increasing the value of the column from where it
left off, regardless of the fact that I deleted all of the data in the
table.
The DB is MS SQL Server 2000.
Thanks and appreciate any help.The only way to do that is to use truncate table instead of delete.
You need additional rights to be able to execute truncate table statement.
Good Luck.
Irina.|||Yes, of course you can use truncate. It will delete and reseed the identity columns.
It is also more efficient way to save the resources.
But, if you also want to use delete, you can reset the identity column by running the following command:
DBCC CHECKIDENT('mytable', RESEED, 0) ;
Hope to help.
No comments:
Post a Comment