Having trouble with Create Index

G

Guest

I'm trying to add a primary key (Unique Index) on a table via a SQL query,
but it's not working the way I expected. My SQL is:

Create Unique Index Unid
On mytable (Id);

I expected Access to add the new column "Id", but the query fails. After I
manually add the new column in the Design view the query runs, but the table
is not changed. I expected unique row numbers to be generated. Finally,
what is the function of index_name? I don't see that it adds anything, but
without it the query fails.

Thanks, Glenn
 
V

Van T. Dinh

Adding Fields (ALTER TABLE SQL) and creating Index (CREATE INDEX SQL) are 2
different actions.

It sound to me that you want to create a COUNTER / AUTOINCREMENT Field
(which is displayed as AutoNumber Field in the Table Design view).

Check the JET SQL Reference section of Access for the capitalised words /
phrases above.
 
G

Guest

Thank you, that worked.

Van T. Dinh said:
Adding Fields (ALTER TABLE SQL) and creating Index (CREATE INDEX SQL) are 2
different actions.

It sound to me that you want to create a COUNTER / AUTOINCREMENT Field
(which is displayed as AutoNumber Field in the Table Design view).

Check the JET SQL Reference section of Access for the capitalised words /
phrases above.
 

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