Click here to Skip to main content
15,883,817 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to get last record from database


is there any similar function as TOP which we use to fetch 1st record

SELECT TOP 1 sponcorid FROM Registration_Master

i want such function to fetch last record
Posted
Updated 16-Nov-12 19:09pm
v2

You could try...

SQL
SELECT TOP 1 sponcorid FROM Registration_Master
order by sponcorid desc 
 
Share this answer
 
Based on unique id number.
SQL
SELECT *
FROM    TABLE
WHERE   ID = (SELECT MAX(ID)  FROM TABLE)


Use this query to get last record from database.
 
Share this answer
 
v2
Comments
sahabiswarup 17-Nov-12 1:31am    
good answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900