Howto: check database fragmentation sql server

Howto: check database fragmentation sql server

How to find all indexes that have fragmentation over 25%:

select * FROM sys.dm_db_index_physical_stats (NULL, NULL, NULL , NULL, 'LIMITED') 
WHERE avg_fragmentation_in_percent > 25.0
 AND index_id > 0
 AND page_count > 1000 
order by avg_fragmentation_in_percent desc

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.