Unique constraints will also allow one NULL, whereas primary keys will not. : Unique « Constraints « SQL Server / T-SQL Tutorial






Unique constraints can be created when initially creating the table or added after.

7> CREATE TABLE Employee (
8>    EmployeeID Int IDENTITY(1,1) NOT NULL
9>   , LastName nVarChar(50) NOT NULL
10>   , FirstName nVarChar(50) NOT NULL
11>   , SSN Char(9) NOT NULL
12>   , CONSTRAINT U_SSN UNIQUE NONCLUSTERED (SSN))
13> GO
1> ALTER TABLE Employee
2> ADD CONSTRAINT U_SSN UNIQUE NONCLUSTERED (SSN)
3> GO
1> drop table Employee;
2> GO








7.10.Unique
7.10.1.Adding a UNIQUE Constraint to an Existing Table
7.10.2.Unique constraints will also allow one NULL, whereas primary keys will not.
7.10.3.Unique Constraint: Enforce uniqueness on a column which is not the column used to primarily identify each row.
7.10.4.Unique constraints can be created when initially creating the table or added after.
7.10.5.Unique constraint
7.10.6.Creating a UNIQUE Constraints when creating a table
7.10.7.Creating UNIQUE Constraints on Existing Tables