Click here to Skip to main content
15,907,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear,
i have a one table where all data of customer availeble. i want to retrive last updated status data from this table of all customer.i needs all customers status
Posted
Updated 16-Feb-12 17:49pm
v2

Unless you date stamp your status, there is no reliable way to do that. SQL does not have to return records in any particular order unless it is specified.

If you do then it is simple:
SQL
SELECT TOP 1 * FROM myTable ORDER BY lastUpdatedDate DESC
 
Share this answer
 
this is one of the best way to see the last update date for a table:

SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_user_update,*
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( 'Databasename')
AND OBJECT_ID=OBJECT_ID('tablename')
 
Share this answer
 
add one filed say createdate in your table and set the default values as getdate() function
now retrieve ur recors like

select * from table order by createdate desc
 
Share this 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