<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SQL Server Maintenance on SQL Server Scripts</title><link>https://www.sqlserver70.com/series/sql-server-maintenance/</link><description>Recent content in SQL Server Maintenance on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Mon, 25 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/series/sql-server-maintenance/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Duplicate and Overlapping Index Detection Script</title><link>https://www.sqlserver70.com/post/sql-server-duplicate-and-overlapping-index-detection/</link><pubDate>Mon, 25 May 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-duplicate-and-overlapping-index-detection/</guid><description>
&lt;p&gt;Duplicate and overlapping indexes waste storage, slow down every write, and split optimizer statistics across redundant copies. This T-SQL script compares each non-heap index in the current database on its first sixteen key columns and surfaces any pair of indexes that overlap, giving the DBA a short list of cleanup candidates.&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;&lt;code&gt;sp_BlitzIndex&lt;/code&gt; does deep usage and statistics analysis across every index. &lt;code&gt;sp_SQLskills_finddupes&lt;/code&gt; factors in INCLUDE columns and sort direction. The script below fills a narrower role between them: a portable, dependency-free first pass for the single most common form of index redundancy — two non-heap indexes on the same table that share a leading key column. The output is a candidate list ready for human triage, not a drop list to apply unattended.&lt;/p&gt;</description></item><item><title>SQL Server VLF Count Report: Virtual Log File Analysis</title><link>https://www.sqlserver70.com/post/sql-server-vlf-count-report/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-vlf-count-report/</guid><description>
&lt;p&gt;Excessive virtual log files (VLFs) inside the transaction log slow down database recovery, backup, and restore operations — often by minutes on large logs — and the problem compounds silently every time autogrowth fires with a small increment. This script queries DBCC LOGINFO across every online database on the instance, counts VLFs and active VLFs per database, and assigns a health assessment so DBAs can prioritize remediation.&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;A SQL Server transaction log is internally divided into virtual log files. SQL Server creates VLFs automatically when the log file grows, and the number of VLFs per growth event depends on the size of the growth increment — small increments create fewer but more numerous VLFs over time, while a single large pre-allocation creates just a handful. When a log accumulates hundreds or thousands of VLFs, SQL Server must scan every VLF header during recovery, log backup, and restore, adding overhead that scales linearly with VLF count. Paul S. Randal of SQLskills.com documented the authoritative research on VLF overhead and the recommended thresholds in his foundational VLF series.&lt;/p&gt;</description></item><item><title>SQL Server DBCC CHECKDB Last Run Date Report</title><link>https://www.sqlserver70.com/post/sql-server-dbcc-checkdb-last-run-date-report/</link><pubDate>Fri, 17 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-dbcc-checkdb-last-run-date-report/</guid><description>
&lt;p&gt;Running &lt;code&gt;DBCC CHECKDB&lt;/code&gt; on every database is one of the most important tasks for a SQL Server DBA. But in busy environments it is easy to lose track of which databases have been checked recently and which have not. This script loops through all user databases, reads the last known good &lt;code&gt;DBCC CHECKDB&lt;/code&gt; date from each one, and presents the results sorted from oldest to newest so you can spot gaps fast.&lt;/p&gt;</description></item><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><item><title>SQL Server DBCC DBREINDEX with Timing: Index Maintenance</title><link>https://www.sqlserver70.com/post/sql-server-dbcc-dbreindex-script-with-timing-database-maintenance-guide/</link><pubDate>Tue, 05 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-dbcc-dbreindex-script-with-timing-database-maintenance-guide/</guid><description>
&lt;h2 id="sql-server-dbcc-dbreindex-script-with-timing---database-maintenance-guide"&gt;SQL Server DBCC DBREINDEX Script with Timing - Database Maintenance Guide&lt;/h2&gt;
&lt;p&gt;Database maintenance is a critical aspect of SQL Server administration, and index rebuilding plays a vital role in maintaining optimal database performance. This comprehensive guide explores powerful DBCC DBREINDEX scripts that include timing functionality to help database administrators monitor and optimize their maintenance operations.
&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;/p&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;The DBCC DBREINDEX scripts presented here are designed to automate the process of rebuilding indexes on all user tables within a SQL Server database. These scripts generate dynamic SQL commands that can be executed to defragment and reorganize table indexes, ultimately improving query performance and database efficiency.&lt;/p&gt;</description></item><item><title>DBCC DBREINDEX: SQL Server Index Rebuild Script</title><link>https://www.sqlserver70.com/post/sql-server-dbcc-dbreindex-script-generator-for-database-maintenance/</link><pubDate>Mon, 04 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-dbcc-dbreindex-script-generator-for-database-maintenance/</guid><description>
&lt;h2 id="sql-server-dbcc-dbreindex-script-generator-for-database-maintenance"&gt;SQL Server DBCC DBREINDEX Script Generator for Database Maintenance&lt;/h2&gt;
&lt;p&gt;Database maintenance is crucial for optimal SQL Server performance, and one of the most important tasks is maintaining database indexes. The &lt;code&gt;DBCC DBREINDEX&lt;/code&gt; command is a powerful tool for rebuilding indexes, but manually running it on every table can be time-consuming. This article explores automated script generation techniques to streamline your database maintenance workflow.
&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;/p&gt;</description></item><item><title>Generate DBCC SHOWCONTIG Commands for All SQL Server Tables</title><link>https://www.sqlserver70.com/post/generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server/</link><pubDate>Fri, 01 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server/</guid><description>
&lt;h2 id="generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server"&gt;Generate DBCC SHOWCONTIG Commands for All User Tables in SQL Server&lt;/h2&gt;
&lt;p&gt;Database administrators frequently need to monitor table and index fragmentation to maintain optimal database performance. This SQL Server script provides an efficient way to generate DBCC SHOWCONTIG commands for all user tables in your database automatically.
&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;/p&gt;
&lt;h2 id="purpose"&gt;Purpose&lt;/h2&gt;
&lt;p&gt;The primary purpose of this script is to dynamically generate DBCC SHOWCONTIG commands for every user table in a SQL Server database. This eliminates the need to manually write individual commands for each table, saving time and ensuring comprehensive fragmentation analysis across all tables.&lt;/p&gt;</description></item></channel></rss>