Adding a UNIQUE Constraint to an Existing Table : Unique « Constraints « SQL Server / T-SQL Tutorial






The syntax is as follows:

ALTER TABLE table_name
ADD CONSTRAINT  constraint_name
UNIQUE  (column [ ASC | DESC ] [ ,...n ] )








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