I want to know what is difference between primary key constraint and unique constraint in SQL Server.
Thank you.
Primary Key Constraint And Unique Constraint in SQL Server
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jul 12, 2012, 1:51 AM EDT
1.Clustered index.only one primary key per table.
2.Doesnt allow null.
Unique key:
1.Non clustered index. you can have as many unique keys in a table.
2.Allows null
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 12, 2012, 2:50 AM EDT
Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.
Thanks