Pages

Google Analytics Alternative

Search This Blog

Friday, November 11, 2011

get Identity column value from Table

hi friends,
today i find one of the good feature to find Identity column from table..

go though with this example

create Table T1(Col1 int identity(1,5),Col2 int)
Go
Insert into T1(Col2) Select 100
Go 100

Select $Identity,* From T1

so at here i am creating one table with having two columns
one is my identity column and another is used to store value (100)
now after creating table at here i am inserting record in it..


Insert into T1(Col2) Select 100
Go 100

Inserting Identity value starting from 1 and seeds to 5 element
like 1,6,11,16,21,26 and so on....

and Go 100 is used for looping that insert statement 100 times..

and i am also selecting 100 value at here..

by using $Identity i can come to know about Identity column value.



No comments: