How to get the value of ID columns from older tables?

  • Thread starter Thread starter JB
  • Start date Start date
J

JB

Hello Community

I have several SQL Server tables with ID columns (the property of the
columns specify that it "Is Identity Yes").

The tables have many rows but I only want the value of the ID column
from a table when the where clause is satisfied.

These are "not" newly inserted in fact these rows can be very old and deep
within the table.

Can anyone tell me how I can extract the value from an Identity column from
a table?

Thanks
Jeff
 
JB said:
Hello Community

I have several SQL Server tables with ID columns (the property of the
columns specify that it "Is Identity Yes").

The tables have many rows but I only want the value of the ID column
from a table when the where clause is satisfied.

These are "not" newly inserted in fact these rows can be very old and deep
within the table.

Can anyone tell me how I can extract the value from an Identity column from
a table?

Thanks
Jeff

You use T-SQL Select statement to select the row like anything else
selected from the table row.

If ID is an Identity field on a table, then it is this.

select ID from table where somefield = parm.

You would only get the resultset back of ID only.

You can then read the resultset using a datareader to access ID in the
resultset.
 
Thank you Mr Arnold

I also saw that there is a keyword named IDENTITYCOL which I can use in
the select statement to capture the IDENTITY.
 
Back
Top