How to create a Primary key with code

Ragalots

New member
Local time
Today, 22:17
Joined
Nov 5, 2001
Messages
5
I have a database that will be receiving an updated table every week called users. This table will replace the older users table. This information is showing me the lastest network users in our company. I need to create in this newly imported table a primary key field. Well I don't need to create it I just need to turn the UserID field into the primary key. I don't really know how to go about this process. Any help would be appreciated. I hope I have given enough information here for somebody to know what I'm taking about.
 
The SQL we are most familiar with is referred to as DML (data manipulation language). And as its name implies, it has to do with adding/changing/deleting data. There is another part of SQL known as DDL (data definition language) which we don't use much in Access since all table objects can be created with the GUI. If you have the Jet SQL help files loaded, you can read all about it. Here's a sample Create Index statement to get you started:

CREATE UNIQUE INDEX UserID ON tblUser (UserID);

Just open a new query, switch to SQL view and type your DDL.

Alternatively, you can use delete and append queries to replace the data in the user table rather than deleting the table object and recreating it. The TransferText Method will append to an existing table if that is how you are getting the new data.
 

Users who are viewing this thread

Back
Top Bottom