Wednesday 18 January 2012

Explain PRIMARY KEY constraint in SQL Server.

The PRIMARY KEY ,

• is used to uniquely identify the records in a table.

• it should not contain NULL values.

• each table should have a PRIMARY KEY.

• each table can have only one PRIMARY KEY.

Ex :

Create Table Suppliers

(

Supplier_ID int NOT NULL PRIMARY KEY,

Supplier_Name varchar (300) NOT NULL,

Address varchar (500),

City varchar (200)

)

This Query creates PRIMARY KEY on the “Supplier_ID” column in suppliers table.

Labels:


Bookmark this Blog in your Favorites