Primary Key new field

  • Thread starter Thread starter Squatt
  • Start date Start date
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
 
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.
 
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.
 
Back
Top