Make table query that adds a Primary Key

Portucale

Registered User.
Local time
Today, 17:52
Joined
Sep 7, 2012
Messages
32
Hi everyone,

I have a make table query that gets its info from another table that is updated weekly. I would like that when we run the Query Type (Make Table), we would like to add a primary key to a field that exists already starting at 1 every time the query is run.

Thanks in advance,
 
SQL is not my best friend, so my approach is like this (see attachment)
It is not exactly a primary key because hasn't this attribute.
But is a number (long) that can start at any value.

Run the query from the button.

Good luck !
 

Attachments

Hi everyone,

I have a make table query that gets its info from another table that is updated weekly. I would like that when we run the Query Type (Make Table), we would like to add a primary key to a field that exists already starting at 1 every time the query is run.

Thanks in advance,

Can you explain a little better because you can't have an autonumber starting at One every time the query is run as this would create duplicate values. Or do you delete the contents of the table, or delete the table and create a new one.

Also why does this field that you want to be autonumber already exist. Can you add a new field later and make that the primary key.

I am assuming you want Autonumber. Please correct me if I am incorrect
 
Code:
[FONT=Times New Roman][SIZE=3]ALTER Table tblTest ADD myField AUTOINCREMENT(1, 1)[/SIZE][/FONT]

This SQL will add a field if this helps.
 

Users who are viewing this thread

Back
Top Bottom