select *
FROM sys.dm_db_index_physical_stats (5, NULL, NULL , NULL, 'LIMITED')
where index_id > 0
order by avg_fragmentation_in_percent desc
- Requête affinée avec le nom de l’index du schéma et de l’objet et le taux de fragmentation
SELECT a.index_id,
OBJECT_SCHEMA_NAME(a.object_id) as Schema_Name,
OBJECT_NAME(a.object_id) as Object_Name,
name, avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(),
NULL, NULL, NULL, NULL) AS a
JOIN sys.indexes AS b
ON a.object_id ###### b.object_id AND a.index_id b.index_id
where a.index_id > 0
order by avg_fragmentation_in_percent desc