Track Table Fragmentation

Here’s a diagnostic table and stored procedure to track the fragmentation of large tables within databases. The user passes the database name and the table name as parameters to the SP. The SP can be set up to run as a scheduled job every few hours to produce a historical trend of fragmentation.

From the author, “While DBCC SHOWCONTIG produced the data I needed, it certainly wasn’t in a friendly form for storage. I use the executable file – OSQL.exe – to process the DBCC command and save its results to a temporary table. The Identity column (Record_Id) allows me to differentiate between the rows so I can apply specific parsing on the target row/content. I’ve augmented the data from SHOWCONTIG to include the Rowcount from the specified table.”

Author: Ralph Clark

Download Script:
Track_Fragmentation.sql



Disclaimer:
We hope that the information on these script pages is
valuable to you. Your use of the information contained in these pages,
however, is at your sole risk. All information on these pages is provided
“as -is”, without any warranty, whether express or implied, of its accuracy,
completeness, or fitness for a particular purpose…

Disclaimer Continued

Back to Database Journal Home

Get the Free Newsletter!

Subscribe to Cloud Insider for top news, trends & analysis

Latest Articles