zoukankan      html  css  js  c++  java
  • Rebuild Index

    SELECT 
    TableID=(SELECT distinct so.name FROM sys.objects so INNER JOIN sys.indexes ON so.object_id = si.object_id)
    ,si.name as Indexname ,
    convert(decimal(9,5),round(ps.avg_fragmentation_in_percent,5)) as Fragmentation, 
    partition_number AS partitionnum,
    ps.OBJECT_ID as objectID,
    ps.index_id AS indexid,
    0 as NewFragmentation 
    FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps 
    INNER JOIN sys.indexes si ON ps.OBJECT_ID = si.OBJECT_ID 
     AND ps.index_id = si.index_id 
    WHERE(ps.database_id = DB_ID() And si.name Is Not null) 
    AND avg_fragmentation_in_percent >= 30
    and ps.index_id<> 0 ORDER BY TableID,Indexname 
    
  • 相关阅读:
    特殊集合
    推箱子
    集合
    数组

    循环语句 练习题
    穷举与迭代
    循环语句
    练习题
    switch case
  • 原文地址:https://www.cnblogs.com/rockchen/p/4218515.html
Copyright © 2011-2022 走看看