Created
January 14, 2014 11:10
-
-
Save eduardosilva/8416713 to your computer and use it in GitHub Desktop.
Returns fragmentation in percentage average for the indexes of a SQL Server database.
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 | |
OBJECT_NAME(F.object_id) AS [table], | |
index_type_desc, | |
avg_fragmentation_in_percent, | |
ISNULL(name,'heap') AS [index] | |
FROM | |
sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS F | |
INNER JOIN | |
sys.indexes AS I ON F.object_id = I.object_id AND F.index_id = I.index_id | |
ORDER BY | |
avg_fragmentation_in_percent DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment