Add unique constraint in SQL Server 2008 GUI?

mezamorphic picture mezamorphic · Nov 30, 2012 · Viewed 45.1k times · Source

I have an existing table with data. I have just added a new column but I cannot find how to add a unique constraint on that column. Could someone please advise? Right-clicking and selecting "check constraints" wasn't helpful.

Answer

marc_s picture marc_s · Nov 30, 2012

You need to right-click in the table designer and pick Indexes/Keys:

enter image description here

Then a dialog pops up and you can add a new index to the list of indices (on the left hand side) and define it to be a unique index:

enter image description here