SELECT
OBJECT_NAME(i.object_id) AS TableName
,
i.name AS TableIndexName
,
phystat.avg_fragmentation_in_percent,
CASE
when phystat.avg_fragmentation_in_percent < 30 then 'Reorganize'
when phystat.avg_fragmentation_in_percent > 30 then 'Rebuild'
END AS 'action_to_take'
FROM
sys.dm_db_index_physical_stats(DB_ID('PUBS'),NULL, NULL, NULL, 'DETAILED') phystat inner JOIN sys.indexes i
ON i.object_id = phystat.object_id
AND i.index_id = phystat.index_id WHERE phystat.avg_fragmentation_in_percent > 10
AND phystat.avg_fragmentation_in_percent < 40
วันอังคารที่ 6 กรกฎาคม พ.ศ. 2553
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น