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

Discussion in 'ASP .Net' started by JB, Feb 20, 2010.

  1. JB

    JB Guest

    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, Feb 20, 2010
    #1
    1. Advertising

  2. JB

    Mr. Arnold Guest

    JB wrote:
    > 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.
     
    Mr. Arnold, Feb 20, 2010
    #2
    1. Advertising

  3. JB

    JB Guest

    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.
    --
    JB


    "Mr. Arnold" wrote:

    > JB wrote:
    > > 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.
    > .
    >
     
    JB, Feb 22, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Van Meer

    display columns from 2 tables in datalist

    Joe Van Meer, May 7, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    336
    Joe Van Meer
    May 7, 2004
  2. Peter Bassett
    Replies:
    3
    Views:
    931
    Augustus
    Aug 15, 2003
  3. Otuatail

    Tables within tables

    Otuatail, Jul 31, 2004, in forum: HTML
    Replies:
    7
    Views:
    498
  4. Replies:
    2
    Views:
    269
  5. Chris Brat
    Replies:
    5
    Views:
    698
    =?iso-8859-1?q?Luis_M._Gonz=E1lez?=
    Aug 22, 2006
Loading...

Share This Page