Primary Key new field

S

Squatt

I have a table full of records and I want to add a new field [with no data]
number data type? and then populate this new field (Autonumbering?) by
running a query or series of queries and once completed - apply the primary
key? Could you help me to identify the correct queries and query sequence
 
D

Daryl S

Sqatt -

Back up your database first.

If you just want an autonumber primary key added, then copy your existing
table, paste it (structure only - no data). Go into this new table and add
the primary key as an autonumber field and save the table.

To get your data into the new table, pull up both the old and new tables in
datasheet mode. In the new table, drag the autonumber field to the right
until it is the last column. Now copy the entire old table (click on the
top-left box just left of the first fieldname and copy) then select the
entire first (blank) row in the new table and paste. Now you can drag the
autonumber field back left so it is the first column if you like. Save the
table.

Check out the data and rename the tables. Done.
 
S

shane

If number sequence is not a concern then you could Create & name the field,
set data type to autonumber, set the field as the primary key. Deleted
records will be skipped in sequence by what record number they originally
were.

As I understand all records have an autoid number, we just don't see them
until we create the field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top