Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Table with SQL

Status
Not open for further replies.

Toyman

Programmer
Jun 19, 2001
68
GB
Hi
How would I create a table using SQL in Access and set the primary key.
This is how I did it in MS SQL
CREATE TABLE mytable(
MyFieldOne VARCHAR(20),
MyFieldTwo VARCHAR(20)

CONSTRAINT PK_MYTABLE PRIMARY KEY (MyFieldOne)
)
GO

Thanks
Toyman
 
I have never tried creating a table in Access code, but you would probably get a faster response if you told us what your problem was. Does this produce an error? Terry M. Hoey
 

THe JET Engine DDL syntax is slightly different from SQL Server DDL Syntax. For a complete JET Syntax listing open the "Microsoft Jet SQL Reference" in Access HELP. Look in the chapter "Data Definition Language."

CREATE TABLE MyTable (MyFieldOne NCHAR VARYING (20) PRIMARY KEY, MyFieldTwo NCHAR VARYING (20))

This example comes from Access 2000 HELP. I don't know if the syntax was different in earlier versions, but I doubt it was. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it if you have time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top