Monday, 27 August 2012

How to Create Identity Incremented By 2 or any no in SQL SERVER

 Some time we Required when we create a table then auto increment id is increment by even no any specific no .

so the solution is here .
We create a table and i want its auto increment id is like 0 , 2 ,4 etc etc

Create table
create table test ( id int identity(0,2), name varchar(10) )

here in Red color if we increase with no 3 then its like 1,3,6 etc etc

 Select * from test
output  is
id   name 

Insert into test values('ROHIT')
Insert into test values('Riya')
Insert into test values('Immy')

Select * from test
output is
id   name
0    ROHIT
2    Riya
4    Immy

Hope this will help you .
Thanks
ROHIT KUMAR SRIVASTAVA

No comments:

Post a Comment