Reputation: 365
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
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