Quantcast
Channel: CodeFari
Viewing all articles
Browse latest Browse all 265

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

$
0
0
One day I got requirement to find last updates of tables in database. Means I want to get all the tables’ last update in 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 above link and try to explain. See following query it may help you to find exact result.


SELECTOBJECT_NAME(OBJECT_ID)ASDatabaseName,last_user_update,*
FROMsys.dm_db_index_usage_stats
WHEREdatabase_id=DB_ID('<your_db_name>')


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


SELECTOBJECT_NAME(OBJECT_ID)ASDatabaseName,last_user_update,*
FROMsys.dm_db_index_usage_stats
WHEREdatabase_id=DB_ID('<your_db_name>')
ANDOBJECT_ID=OBJECT_ID('table_name')





Viewing all articles
Browse latest Browse all 265

Trending Articles