Is there a method to fetch the last value stored in a DB column with out having to read in the entir

Discussion in 'ASP .Net' started by DeWitt Phillips, Dec 12, 2003.

  1. First let me say thank you. I am trying to extract the last value entered
    into a database column without having to read through every value stored in
    the column. Is that something that is easy to do?
     
    DeWitt Phillips, Dec 12, 2003
    #1
    1. Advertising

  2. It is easy if there's a column with a datetimestamp. You would just use the
    datetimestamp in the WHERE clause, set the order to DESC and pick off the
    very first record.

    "DeWitt Phillips" <> wrote in message
    news:tFaCb.611$pm5.382@okepread01...
    > First let me say thank you. I am trying to extract the last value entered
    > into a database column without having to read through every value stored

    in
    > the column. Is that something that is easy to do?
    >
    >
     
    Ken Cox [Microsoft MVP], Dec 12, 2003
    #2
    1. Advertising

  3. DeWitt Phillips

    Joe Gass Guest

    Providing you have a consectutive identity, then ordering by this in a
    desending order - then selecting the first row (top 1)

    e.g.
    select top 1 yourField from yourTable order by id desc


    "DeWitt Phillips" <> wrote in message
    news:tFaCb.611$pm5.382@okepread01...
    > First let me say thank you. I am trying to extract the last value entered
    > into a database column without having to read through every value stored

    in
    > the column. Is that something that is easy to do?
    >
    >
     
    Joe Gass, Dec 12, 2003
    #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. Hai Nguyen
    Replies:
    0
    Views:
    415
    Hai Nguyen
    Jan 16, 2004
  2. Cal
    Replies:
    1
    Views:
    555
    Tim B
    Jan 8, 2007
  3. Barry
    Replies:
    9
    Views:
    1,416
    Kushal Kumaran
    May 27, 2010
  4. Helge Elvik
    Replies:
    4
    Views:
    124
  5. thunk
    Replies:
    8
    Views:
    146
    thunk
    Mar 27, 2010
Loading...

Share This Page