At times there may be need to find when was the last activity done on a database. This also might help you to clean up old unused databases on a SQL Server Instance.
I found out below query with slight modifications of mine.
You can Modify the Order By Criteria as per you convinience.
USE [YOURDATABASENAME]
GO
SELECT
T.NAME
,USER_SEEKS
,USER_SCANS
,USER_LOOKUPS
,USER_UPDATES
,LAST_USER_SEEK
,LAST_USER_SCAN
,LAST_USER_LOOKUP
,LAST_USER_UPDATE
FROM
SYS.DM_DB_INDEX_USAGE_STATS I JOIN
SYS.TABLES T ON (T.OBJECT_ID = I.OBJECT_ID)
WHERE
DATABASE_ID = DB_ID('YOURDATABASENAME')
ORDER BY LAST_USER_SEEK DESC
No comments:
Post a Comment