Preferably I would like to know how to do it using the SQL Server Management Studio interface but that isn't completely necessary. If you simply have a script to add one after a table is made that would be fine.
+2
A:
Try this:
ALTER TABLE dbo.YourTableName
ADD CONSTRAINT
ConstraintName UNIQUE NONCLUSTERED
(
Column01,
Column02,
Column03
)
I use business names for constraints so that if it is violated and an exception bubbles up, I get "Only one Dept per Employee violation" in my error message rather than "ConstraintXXX violation".
Raj More
2009-11-03 23:08:36
Cool. It seems strange that this is in the indexes section instead of the constraints section
Joe Philllips
2009-11-04 15:30:54
A Unique Constraint is basically handled by a Unique Index - that's why.
marc_s
2009-11-04 15:32:59