索引 碎片

 a. avg_fragmentation_in_percent AS 碎片,  c. NAME + '.' + b. NAME  AS 表名

         

FROM sys.dm_db_index_physical_stats ( DB_ID (), NULL, NULL , NULL, 'LIMITED' ) AS a



    INNER JOIN sys.objects AS b ON a. object_id = b. object_id



    INNER JOIN sys.schemas AS c ON c. schema_id = b. schema_id



    INNER JOIN sys.indexes AS d ON d. object_id = a. object_id AND d. index_id= a. index_id



    INNER JOIN ( SELECT object_id , index_id, partitioncount= COUNT (*) FROM sys.partitions GROUP BY object_id , index_id) AS e ON e. object_id = a. object_id AND e. index_id= a. index_id



WHERE a. avg_fragmentation_in_percent > 10.0 AND a. index_id > 0 AND d. Name IS NOT NULL 

 
   
 
   
http://blog.csdn.net/roy_88/article/details/6163583

  

你可能感兴趣的:(索引)