-
-
Save richard24se/cee93bab3e3029bda0c72cf69ec3033f to your computer and use it in GitHub Desktop.
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 DB_NAME (database_id) AS [Database Name], OBJECT_NAME(ps.object_id) AS [Object Name], | |
i.name AS [Index Name], ps.index_id, index_type_desc, | |
avg_fragmentation_in_percent, fragment_count, page_count | |
FROM sys.dm_db_index_physical_stats(DB_ID(),NULL, NULL, NULL ,N'LIMITED') AS ps | |
INNER JOIN sys.indexes AS i WITH (NOLOCK) | |
ON ps.[object_id] = i.[object_id] AND ps.index_id = i.index_id | |
WHERE database_id = DB_ID() | |
AND page_count > 1500 | |
ORDER BY avg_fragmentation_in_percent DESC OPTION (RECOMPILE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment