SQL Server Archives - Coding Sharp

Tag: SQL Server

Difference between Primary Key and Unique Key in SQL Server

Difference between Primary Key and Unique Key in SQL Server

SQL Server
In our previous article we have see the difference between Asp.Net Web Form and Asp.Net MVC, today we will see the difference between PK and UK. Difference between Primary Key and Unique Key in SQL Server Primary Key Unique Key Primary Key creates a Clustered index Unique Key creates a Non Clustered Index Primary Key does not allow null value Unique Key allows only 1 null value. A table can have only 1 Primary Key A table can have more then 1 Primary Key Primary Key is a unique key identifier of the record Unique-key is to prevent duplicate values in a column Primary Key has to be unique. Unique Key does not have to be the primary key. In Primary Key column you can't delete or change the value In Unique Key column you can delete or changes it'...