参考sys.dm_db_index_physical_stats
检查索引碎片情况
1.SELECT
2.OBJECT_NAME(object_id) as objectname,
3.object_id AS objectid,
4.index_id AS indexid,
5.partition_number AS partitionnum,
6.avg_fragmentation_in_percent AS fra
7.FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, ‘LIMITED')
8.WHERE