Reset table autonumber with Microsoft SQL Management Studio Express (SQL 2005)

Hi Experts,

Excuse my ignorance on this one.  I have an SQL 2005 database and using Studio Express to look at the data etc.  I have cleared all the data from the tables but cannot see how to reset the autonumbers in each table back to 1.  Is there a simple way of doing this?  With Access I use 'Compact and Repair' - is there something similar with Studio Express?

Many thanks, Rob
robfendergibsonAsked:
Who is Participating?
 
mohan_sekarCommented:
DBCC CHECKIDENT (tblName, RESEED, 0)
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
another option is to TRUNCATE the table instead of clearing the data and the resetting the identity seed

truncate table
0
 
BrandonGalderisiCommented:
or, if you issue a truncate table when deleting all records it will reset the identity value as well as deleting the data.  This however, will not work on tables referenced by foreign keys.
0
 
robfendergibsonAuthor Commented:
Thanks Mohan, going with yout solution as the first one nad worked fine.  Also thanks to other contributers.

best wishes, Rob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.