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 strongm 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 auto increment field? 1

Status
Not open for further replies.

lemonjuice

Programmer
Jun 12, 2003
62
ZA
How do I reset the auto increment of a table's primary key field(fieldtype + )to zero?
 
lemonjuice,

The short answer is, "You're not supposed to do that." The idea is that AI fields shouldn't be modified.

The only way to do this is to create a new table by borrowing the structure of the old table and then to add the data from the old table to the new copy.

Hope this helps...

-- Lance
 
Lemonjuice,

You should also be able to recreate the auto increment field by removing the key from the table, deleteing the AI field and restructuring the table. Then replace the key and add a new AI field and restructure again. Keep in mind this may not work as easily as it sounds depending on how Referential Integrity is set on the table. But as lance said "You're not supposed to do that" If you care what numbers are in the AI field then you should probably be using a Numeric field and not an AI field.

Perrin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top