<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Rebuild Reorganize on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/rebuild-reorganize/</link><description>Recent content in Rebuild Reorganize on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Fri, 03 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/rebuild-reorganize/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Index Fragmentation: dm_db_index_physical_stats</title><link>https://www.sqlserver70.com/post/sql-server-index-fragmentation-sys-dm-db-index-physical-stats/</link><pubDate>Fri, 03 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-index-fragmentation-sys-dm-db-index-physical-stats/</guid><description>
&lt;h2 id="report-index-fragmentation-across-all-tables-in-sql-server"&gt;Report Index Fragmentation Across All Tables in SQL Server&lt;/h2&gt;
&lt;p&gt;This script queries &lt;code&gt;sys.dm_db_index_physical_stats&lt;/code&gt; to report external and internal fragmentation for every index in the current database, filtering to indexes with significant fragmentation and enough pages to make maintenance worthwhile.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;Index fragmentation is one of the most common causes of gradually degrading query performance in SQL Server. As rows are inserted, updated, and deleted, index pages become out of order (external fragmentation) and partially empty (internal fragmentation). Both conditions force SQL Server to read more pages than necessary to satisfy a query. The &lt;code&gt;sys.dm_db_index_physical_stats&lt;/code&gt; dynamic management function scans index structures and reports fragmentation levels, giving DBAs the data needed to decide which indexes should be rebuilt and which should be reorganized. This script, adapted from the DBA-Scripts collection by Bulent Gucuk, runs against all tables in the current database and filters the output to actionable results.&lt;/p&gt;</description></item></channel></rss>