Link to home
Start Free TrialLog in
Avatar of swuit
swuitFlag for United States of America

asked on

Retrieve last record

I have an SQL database with thousands of records in it. The "formnumber" field is set as the key. I am writing a VB.NET application and one of the fields will require me to pull the last record in the database. I don't want to read in all the records and then sort them. Is there a way to sort the data and then read in the last record?
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Key is to sort in descending order.
Then use Top 1 to get the first record.
So effectively, you are getting the last record.

hongjun