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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

resetting IDENTITY column

Status
Not open for further replies.

k108

Programmer
Jul 20, 2005
230
US
Hi,

Is there a way to re-set the values in an identity column w/o dropping and recreating the table?

That is, I would like to start the identity column numbers at 1.

Thank you
 
Truncate table Tablename

That will reset the identity to 1.

Regards,
AA
 
Another option is:

DBCC CHECKIDENT (TBLName, RESEED, 1)


Sunil
 
Thanks for the info. Interestingly, I just read something about the TRUNCATE command. It said that if you issue a TRUNCATE command, it invalidates the the transaction log for the entire database, and can't be backed up until the next full database backup!

I have never heard of such a thing (not in Oracle at least).

This seems pretty lame to me. But what do I know.
 
If you want to start at 1 use:

DBCC CHECKIDENT (TysonTest, RESEED, 0)

Using DBCC CHECKIDENT (TysonTest, RESEED, 1)

will make the identity in the next insert into an empty table 2.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top