Created
September 4, 2013 10:10
-
-
Save codingbadger/6435131 to your computer and use it in GitHub Desktop.
Lists all Indexes and their fragmentation
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 ps.database_id, ps.OBJECT_ID, | |
ps.index_id, b.name, | |
ps.avg_fragmentation_in_percent | |
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps | |
INNER JOIN sys.indexes AS b ON ps.OBJECT_ID = b.OBJECT_ID | |
AND ps.index_id = b.index_id | |
WHERE ps.database_id = DB_ID() | |
ORDER BY ps.avg_fragmentation_in_percent desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment