Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Reset AutoNumber ID

Status
Not open for further replies.

essa2000

Programmer
Dec 6, 2000
299
CA
Dears ;
I want to reset unique ID of a table which is of type AutoNumber in SQL Server 7.0 Database. When , I delete records then the next is greater than previous one. Is there any solution.

Regards,
essa2000
 
Truncate table will reset the id back to it's initial value and delete the rows. Just keep in mind that it is not logged and is therefore, unrecoverable.

If you have deleted all of the rows, then you can also safely use DBCC CHECKIDENT ('table_name', RESEED, new_reseed_value) as in: DBCC CHECKIDENT ('authors', RESEED, 1)... I wouldn't use this approach if you are trying to reseed the seed to a value that is less than an existing value, which will cause problems... Tom Davis
tdavis@sark.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top