Wednesday, 20 March 2013

SQL 2008: How to make a column Unique


Add a unique constraint for that column:
alter table Foo add constraint UQ_Name unique (Name)
To add it through SQL Management Studio UI:
  1. Open SQL Server Management Studio.
  2. Expand the Tables folder of the database where you wish to create the constraint.
  3. Right-click the table where you wish to add the constraint and click Design.
  4. In Table Designer, click Indexes/Keys.
  5. Click Add.
  6. Choose Unique Key in the Type drop-down list.

No comments:

Post a Comment