Syntax for UNIQUE constraint?

G

Guinness Mann

I have an existing table:

CREATE TABLE TestQuestions (
qId int NOT NULL IDENTITY(1,1)
CONSTRAINT PK_TestQuestions PRIMARY KEY NONCLUSTERED,

testId int NOT NULL
REFERENCES Tests(testId)
ON DELETE CASCADE,

objectiveId varchar (30) NULL

qType int NOT NULL
CONSTRAINT DF_TestQuestions_qType DEFAULT (0),
)

And I'd like to add the constraint:

ALTER TABLE TestQuestions ALTER COLUMN objectiveId
CONSTRAINT U_TestQuestions UNIQUE NONCLUSTERED (testId, objectiveId)

Although obviously that's not the correct syntax. Could you tell me
what *is* the correct syntax?

Thanks,

-- Rick
 

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

Members online

Forum statistics

Threads
474,132
Messages
2,570,775
Members
47,332
Latest member
datacos561

Latest Threads

Top