SQL Server- How to get last access/update time for tables in Database?

One day I got a requirement to find last updates of tables in the database. Means I want to get all the tables’ last update in the database and did surfing on google and found the best way. Link: https://blog.sqlauthority.com/2009/05/09/sql-server-find-last-date-time-updated-for-any-table/

I am taking reference from the above link and try to explain. See the following query it may help you to find the exact result.


SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_user_update,*
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( '<your_db_name>')


If you want to see the last update of particular the table then use the following query.


SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_user_update,*
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( '<your_db_name>')
AND OBJECT_ID=OBJECT_ID('table_name')




PostgreSQL-Query: Sort result set by specific field values using ORDER BY Clause

Problem: Suppose we have a book_inventory table which has some columns such as id, isbn, title, author, publisher, publish_date, etc.. whe...