Created
May 13, 2022 15:47
-
-
Save Otterpohl/19efc96e35eadf83b9b44e2164f1f42a to your computer and use it in GitHub Desktop.
Get a tables last scan, seek, lookup and update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t.name, | |
MAX(us.last_user_seek) AS last_user_seek, | |
MAX(us.last_user_scan) AS last_user_scan, | |
MAX(us.last_user_lookup) AS last_user_lookup, | |
MAX(us.last_user_update) AS last_user_update | |
FROM sys.dm_db_index_usage_stats AS us | |
JOIN sys.tables AS t | |
ON t.object_id = us.object_id | |
WHERE us.database_id = DB_ID() | |
GROUP BY t.name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment