<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Data Compression on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/data-compression/</link><description>Recent content in Data Compression on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Tue, 30 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/data-compression/index.xml" rel="self" type="application/rss+xml"/><item><title>Apply Row and Page Compression to Tables and Indexes</title><link>https://www.sqlserver70.com/post/sql-server-compress-tables-and-indexes-script/</link><pubDate>Tue, 30 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-compress-tables-and-indexes-script/</guid><description>
&lt;p&gt;Storage budgets shrink faster than databases grow. Uncompressed tables and indexes often carry two to four times the physical page count that row or page compression would require — a gap that widens with every batch load or continuous INSERT. &lt;code&gt;sys.dm_db_index_physical_stats&lt;/code&gt; joined to &lt;code&gt;sys.partitions&lt;/code&gt; surfaces every uncompressed index and heap in a database in one pass, and the script below converts that inventory into ready-to-execute &lt;code&gt;ALTER INDEX REBUILD&lt;/code&gt; and &lt;code&gt;ALTER TABLE REBUILD&lt;/code&gt; statements sorted by object size so the highest-impact targets come first.&lt;/p&gt;</description></item></channel></rss>