小编Pru*_*Raj的帖子

验证此 TSQL 以查找碎片化超过 50% 的索引

select 
OBJECT_SCHEMA_NAME(IPS.object_id) 'schema',
  OBJECT_NAME(IPS.object_id) as table_name,index_type_desc,
  round(avg_fragmentation_in_percent,2) 'avg_fragmentation_in_percent',
  si.name
   from  sys.dm_db_index_physical_stats(db_id(DB_NAME()),null, 
   NULL, NULL , 'DETAILED') AS IPS inner join  sys.indexes si on 
   si.object_id=IPS.object_id
   where
   index_type_desc <> 'HEAP' and avg_fragmentation_in_percent >=50
   order by avg_fragmentation_in_percent desc
Run Code Online (Sandbox Code Playgroud)

index sql-server-2008 sql-server t-sql fragmentation

-1
推荐指数
1
解决办法
361
查看次数