M. Smith
M. Smith

Reputation: 365

How do you make a non-key column unique in SSMS?

In SQL Server Management Studio (SSMS) I have a table with a numeric, surrogate primary key. I would like to make another column unique, however. It seems like only primary keys can be made unique, however.

How does one make a non-key column unique, so that the same value may not be entered twice?


SQL Server 2012, SSMS 2012


Also, if it matter, I used a numeric surrogate key on the table instead of a natural key because values in the column above, that I need to make unique, may change in the future.

Upvotes: 2

Views: 1766

Answers (1)

Daniel A. Thompson
Daniel A. Thompson

Reputation: 1924

It seems like only primary keys can be made unique, however.

Try using a unique constraint: https://msdn.microsoft.com/en-us/library/ms190024.aspx

Upvotes: 2

Related Questions