Saturday, April 14, 2012

How to create table in SQL Server with primaryKey and autoIncrement

Syntax to create primary key

create table tablename
(
     "Column 1" "data_type_for_column1" primary key,
     "Column 2" "data_type_for_column2"
)

Example :-

create table userinfo
(
   sno int primary key identity(1,1) ,
   firstname varchar(50),
   lastname varchar(50),
   designation varchar(50),
   sal float
)

No comments:

Post a Comment