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

D

DeWitt Phillips

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?
 
K

Ken Cox [Microsoft MVP]

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

Joe Gass

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top