Tuesday, March 20, 2012

Primary Key auto-increment reset

Ok - I have two tables that are relational. I have been inserted data into the tables because of testing. I also have been deleting data. My question is how do I reset the auto-incremented Primary key values.

For example:

Primary key of table one is bizID. Well there are only 3 record currently in the table. The bizIDs are 1-3. If I insert another record the bizID will be 88 because that was the next auto-incremented number. I obviously deleted the other records. I want to start the primary key value over from zero. How do I accomplish this? thnks

What you want is to RESEED the value. Check out Books On Line for more info. Also, when you are done with your testing and want to start from 0, you can do a TRUNCATE TABLE <table>.

DBCC CHECKIDENT (jobs, RESEED, 30)

No comments:

Post a Comment