Checking SQL server fragmentation and fixing

SELECTOBJECT_NAME(OBJECT_ID), index_id,index_type_desc,index_level,

avg_fragmentation_in_percent,avg_page_space_used_in_percent,page_count

FROMsys.dm_db_index_physical_stats

(DB_ID(N’db_name’),NULL,NULL,NULL,‘SAMPLED’)

ORDERBY avg_fragmentation_in_percent DESC

Leave a Reply

Your email address will not be published. Required fields are marked *