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
 Transact-SQL (2000)
 Identity after delete

Author  Topic 

ratcho
Starting Member

18 Posts

Posted - 2002-09-06 : 12:16:57
Hi again!

I would like to ask you the following question. I have a table (TheTable) and its column (TheKey) for which Identity=yes. If I delete all the records:

delete from TheTable;

and than if I insert new record, the value of TheKey wont be 1, but the next value determined by IdentitySpeed.

Is there any way to start at the beginning?

Thanks a lot! You are great!

davidfb
Starting Member

8 Posts

Posted - 2002-09-06 : 12:25:45
Try using this command:

DBCC CHECKIDENT ('TheTable', RESEED, 0)


David


Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-09-06 : 12:40:18
Additionally, if you will always be deleting all the rows in the table, you can use the TRUNCATE TABLE command. It's faster, empties the whole table, and automatically resets the identity seed. See Books Online for more details.

Go to Top of Page
   

- Advertisement -