Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Primary key

Author  Topic 

skillile
Posting Yak Master

208 Posts

Posted - 2001-12-13 : 11:14:54
After deleting all the records in a table
with a primary key.

How do you reset the key value to 1 without
droping it and recreating it.



slow down to move faster...

shankarc
Starting Member

37 Posts

Posted - 2001-12-13 : 11:40:23
On the assumption that your Primary key is an Identity column, i am continuing....

You can use Truncate Table instead of Delete.

TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes and so on remain. "The counter used by an identity for new rows is reset to the seed for the column. "

So just set your seed to 1 and use Truncate table.

Go to Top of Page

izaltsman
A custom title

1139 Posts

Posted - 2001-12-13 : 11:40:53
You mean an identity column?
See DBCC CHECKIDENT in BOL

Go to Top of Page
   

- Advertisement -