Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 6369 | Views in the last 30 days: 9
 
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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones