TSQL – Last Time Table was Updated

If you looking for a script to find out when was the last time a particular table was updated then here it is:

SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_user_update,*
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( 'DATABASENAME')
sys.dm_db_index_usage_stats ius INNER JOIN
sys.tables tbl ON (tbl.OBJECT_ID = ius.OBJECT_ID)
WHERE ius.database_id = DB_ID()

This normally happens when you don’t have columns such as DateCreated and UpdatedDate in the table.

Live as if you were to die tomorrow. Learn as if you were to live forever.. -Mahatma Gandhi

Leave a Reply

Your email address will not be published. Required fields are marked *