Unique ID for existing table

60 pts.
Tags:
Auto increment
Database design
Database programming
SQL
I want to add a column to an existing table where its values should be unique and auto generated in a sequential order

Answer Wiki

Thanks. We'll let you know when a new response is added.

This could be different depending on the database, which you didn’t specify.

If you already have data in the table, you will probably need to create a stored procedure to generate the sequential number for the existing records, and then set a trigger up to auto-generate the number when new records are inserted.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • SbElectric
    In Access 2007. Just define a field (say Key1) & select AutoNumber. Under field properties: Index – select (Yes, (No Duplicates). Of course, this assumes you do not have a key field already defined.
    2,540 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following