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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNIQUE equivalent

Status
Not open for further replies.

Amir88

Programmer
Jan 8, 2005
4
0
0
CA
hello everyone, I wanted to know the equivalent for the keyword 'UNIQUE' which is used in SQL to make two columns into a Composite key, in MS-Access.

If you do not know about the UNIQUE keyword in SQL, basically all I want is to make to columns a composite key. Meaning: Just Like if you were to make them primary keys except they are not primary keys they just follow the validation rule:

example

X Y
1 1
1 2
3 2
2 1

If X and Y were composite keys, I could add any value in X and any value in Y as long as I don't repeat the values leading to them

for example 3 2 is not permitted because it already exists but 3 1 and 2 2 is because only one of the keys is repeated and not both. if that made any sense please help...
 
JetSQLhelp said:
CREATE [ UNIQUE ] INDEX index
ON table (champ [ASC|DESC][, champ [ASC|DESC], ...])
[WITH { PRIMARY | DISALLOW NULL | IGNORE NULL }]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the quick reply. But Im using Ms-Access where do I put your SQL code

CREATE [ UNIQUE ] INDEX index
ON table (champ [ASC|DESC][, champ [ASC|DESC], ...])
[WITH { PRIMARY | DISALLOW NULL | IGNORE NULL }]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top