Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Index Fragmentation for All Databases

By Jon Morisi,

You can change 'limited' to 'sampled' or 'detailed' for more in depth scanning of the indexes
Remove this where clause if you would like to see system DBs (Where DatabaseID > 4)
Increase or decrease this where clause to adjust the number of fragments per db returned (Where i.rnk <= 25)
Due to the use of DB_ID, the compatibility level all databases must be 90.
INDEX_ID > 0 omits heap data
Page_Count > 500 omits indexes with less than 500 pages where defragmentation would not necessarily be helpful

 

Total article views: 6562 | Views in the last 30 days: 8
 
Related Articles
FORUM

Index

index

ARTICLE

Where Do I Want To Go Today? - Index Tuning Wizard

Where should SQL Server go in the future? Steve Jones continues to explore his wish list for future ...

ARTICLE

Where Do I Want To Go Today? - Bidirectional Indexes

Where should SQL Server go in the future? Steve Jones continues to explore his wish list for future ...

FORUM

Question about included columns in nonclustered indexes: Where exactly are they stored?

Do nonclustered indexes just store pointers to clustered indexes?If so where are the included column...

Tags
fragmentation    
indexing    
 
Contribute