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.


Enroll Today!
SteveStedman5
SteveStedman5
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!

Leave a Reply

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

*

To prove you are not a robot: *