I have SQL Server 2008 R2 and I want to set a unique column.
There seems to be two ways to do this: "unique index" and "unique constraint". They are not much different from what I understand, although unique constraint is recommended by most, because you also get an index automatically.
How do I create a unique constraint?
ALTER TABLE Customer ADD CONSTRAINT U_Name UNIQUE(Name)
Is there a way to create a unique constraint through the SQL Server Management Studio?
They really make you run around the barn to do it with the GUI:
Make sure your column does not violate the unique constraint before you begin.
alter table location_key drop constraint pinky;
alter table your_table add constraint pinky unique(yourcolumn);
Changes take effect immediately:
Command(s) completed successfully.