TSQL to find index fragmentation in SQL Server

To determine index fragmentation in SQL Server, you can use the following steps: SELECT OBJECT_NAME(DMV.object_id) AS TABLE_NAME , SI.NAME AS INDEX_NAME , avg_fragmentation_in_percent AS FRAGMENT_PERCENT , DMV.record_count FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, ‘SAMPLED’) AS DMV LEFT OUTER JOIN SYS.INDEXES AS…

Read More →