views:

1471

answers:

3

In my TSQL table I added a constraint with the following sQL statement

alter table disabledqualities
add constraint uc_uIdQualCode
unique (userId, qualitycode)

I did it by hand because I just can't work out how the GUI is supposed to work.
You add a constraint and then you get a window where you should "define" your constraint. It's basically just a textbox. And no matter what I seem to enter, it never validates..

What am I supposed to enter in the box?

+1  A: 

Example, column must be between 0 and 1,

((0)<=[TABLE].[COLUMN] AND [TABLE].[COLUMN]<=(1))

When adding unique constraints, it's actually an index, like primary key, so you click on indexes/keys.

marr75
+2  A: 

you would use new index not new constraint to add a unique constraint (read index) new constraint is to add check constraints

in the new index window check unique

SQLMenace
I should have known that a unique CONSTRAINT is not in the CONSTRAINT dialogue. Is it just me or does sql server management studio really suck?
borisCallens
these are semantics really, if you look under keys you will find Primary Key Constraints there....I guess you have to know where to look :-(...I doubt people would want to find a Primary Key under constraints....
SQLMenace
Yes, you are probably right. I just seem to have a personal issue with studio. Thanks for the help.
borisCallens
A: 

I think it is fair to be a little confused since you use "Add Constraint" to create the unique constraint... and the documentation also says "Unique Constraint".

But, oh well!

mike