Select Page

TSQL To Find Fragmented Indexes

Prior to the Database Health Reports with the Fragmented Indexes Report, I used the following query to track down fragmented indexes.

SELECT ps.avg_fragmentation_in_percent, name
  FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps
 INNER JOIN sys.indexes AS idxs 
    ON ps.OBJECT_ID = idxs.OBJECT_ID 
   AND ps.index_id = idxs.index_id

But now it is so much easier with the Database Health Reports with the Fragmented Indexes Report.

Submit a Comment

Your email address will not be published. Required fields are marked *

To prove you are not a robot: * Time limit is exhausted. Please reload CAPTCHA.