Created
January 4, 2017 07:47
-
-
Save bartread/4b9438fce3dd6fcb4f6c4e0f2b2fd2a7 to your computer and use it in GitHub Desktop.
Get most used tables in SQL Server
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
--get most used tables | |
SELECT | |
db_name(ius.database_id) AS DatabaseName, | |
t.NAME AS TableName, | |
SUM(ius.user_seeks + ius.user_scans + ius.user_lookups) AS NbrTimesAccessed | |
FROM sys.dm_db_index_usage_stats ius | |
INNER JOIN sys.tables t ON t.OBJECT_ID = ius.object_id | |
WHERE database_id = DB_ID('YOUR_DATABASE_HERE') | |
GROUP BY database_id, t.name | |
ORDER BY SUM(ius.user_seeks + ius.user_scans + ius.user_lookups) DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment