How To Create Table In SQL Server 2008 With ID Auto-Increment

How To Create Table In SQL Server 2008 With ID Auto-Increment

In this tutorial i will let you know How To Create Table In SQL Server 2008 With ID Auto-Increment, by itself by number you have given when creating table.By this when you insert data into table then that column which have Auto Increment is on keep on Incremented by Itself.

SQL script for this is following:-

use master

go

create table test( id int primary key identity(1,1),

name varchar(50)notnull,

class varchar(50)notnull )

go

---insert dummy data into table----

insert into test values ('test','Sixth')

insert into test values ('test','Sixth')

insert into test values ('test','Sixth')

go

-- Now select the data from table----

select * from rom test

Result will be like this:-


Share This Post: