Create table statement constraint syntax

A

April

As part of a school assignment, I must create a table using an SQL statement
in Microsoft access 2003. My statement works and the table is visible there
ready to receive data. However, I was supposed to put a constraint on one of
the numeric fields that will restrict entries to numbers less than 150.

I can't figure out the syntax to create this validation rule in the Make
Table statement. I tried CONSTRAINT keyword and CHECK keyword but keep
getting an error. Is this not supported by the Jet engine 4.0 ?
 
A

April

hhhmmm... tried your suggestion. Doesn't seem to work in a Create table
statement. still getting an error message. Maybe I should post my original
statement. here it is:

CREATE table patients
(PID char(15) not null primary key,
FName varchar(25) null,
LName varchar(25) null,
Address varchar(50) null,
City varchar(25) null,
ST char(2) null,
Zip char(10) null,
Phone char(12) not null,
age integer null,
CHECK([age]<150));
 
E

Evi

Have a go doing this with an actual query then read the Sql produced.
ie make a table with some numbers in it, put it in a query grid and filter
using <150. Turn this Select Query into a Make Table query using the Query
Type button then read the Sql in the Query's Design view by pressing the
black arrow just next to the View button

Evi
 

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