Thursday , October 18 2018
Home / DataBase / SQL SERVER / Create Unique Constraint In Sql Server

Create Unique Constraint In Sql Server

Create Unique Constraint In Sql Server

Unique Constraint:-  When  we  place UNIQUE constraint on any column ,It will not allow duplicate values but it allows single null value.

Unique  Key Constraints can be imposed in two different ways:

1.Column Level Definition

2.Table Level Definition

Column Level Definition: In this case the constraint definition is immediately followed after the column definition. The syntax is:

Example:-

 

 

Table Level Definition: Here constraints are going to be placed on columns after the definition of all columns and their corresponding data types. It means at the end of the table definition constraints will be placed on columns.

The syntax is:

Example:

 

Print Friendly, PDF & Email

Give us your valuable feedback

comments

About Samba

Check Also

sql server backup script

Backup all databases in SQL Instance with one script

Backup: A copy of SQL Server data that can be used to restore and recover the …