Tuesday , June 19 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

Find all rows count and columns count in single database in sql server

In General for any database it contains lot of tables, if we want to find …

%d bloggers like this: