How to make “No Duplicates” column in SQL Server 2008?

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 on Indexes/Keys.
  5. Click Add.
  6. Choose Unique Key in the Type drop-down list.

To handle a situation where a unique constraint violation occurs, see for error 2601.

Leave a Comment