I want to know what is difference between primary key constraint and unique constraint in SQL Server.
Thank you.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jul 12, 2012, 6:50 AM
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
Santhosh Kumar JayaramanPosted Jul 12, 2012, 5:51 AM
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