Detect Suspect Database Pages with msdb.dbo.suspect_pages
Jul 2, 2026 / · 10 min read · sql server suspect pages msdb database corruption page corruption dbcc checkdb integrity check maintenance storage error scripts sys.master_files ·Storage errors do not always surface as immediate failures. When SQL Server hits an 823 or 824 error while reading a database page, it records that page in msdb.dbo.suspect_pages — a system table in msdb that keeps one row per suspect page until someone deletes it. Querying this table is the fastest first pass in any …
Read MoreApply Row and Page Compression to Tables and Indexes
Jun 30, 2026 / · 11 min read · sql server data compression sys.dm_db_index_physical_stats sys.partitions sys.indexes sys.objects sys.schemas row compression page compression index maintenance maintenance scripts ·Heaps and indexes that were never compressed keep occupying full-size pages, and nothing in a default database flags them. sys.dm_db_index_physical_stats joined to sys.partitions lists the uncompressed heaps and indexes above a size threshold, and the script below turns that list into ready-to-review ALTER INDEX ... …
Read MoreHow to Update Statistics in SQL Server
Statistics are the optimizer's picture of the data, and that picture ages every time rows change. When a table grows faster than its statistics are refreshed, plans keep being built for the row counts it held weeks ago. Refreshing the statistics is often the fix, and the work is knowing which ones to refresh and with …
Read MoreSQL Server DBCC Commands Guide
Jun 8, 2026 / · 10 min read · sql server dbcc commands database maintenance database administration maintenance scripts sql scripts consistency checks dbcc checkdb dbcc shrinkfile plan cache sys.dm_exec_requests sys.dm_db_log_space_usage sys.dm_exec_cached_plans sys.dm_exec_input_buffer sys.dm_exec_sql_text ·An incident rarely announces which DBCC statement it needs. A log file stops truncating, a query slows after a plan changes, an identity column runs ahead of its table, and each one has a Database Console Command that answers it, sitting next to a few that can make the same situation worse. The DBCC statements are …
Read MoreSQL Server DBCC CHECKDB Guide and Repair Options
Jun 7, 2026 / · 10 min read · sql server database corruption consistency checks database maintenance dbcc commands database administration maintenance scripts sql scripts dbcc checkdb sys.databases ·Running DBCC CHECKDB on a schedule is only the start, because its options change what it checks, how long it takes and what it can do to your data. This post covers the check options, a script that runs the command against every online user database, and the three repair levels, including why REPAIR_ALLOW_DATA_LOSS is …
Read MoreSQL Server DBCC SHRINKDATABASE: When and When Not to Shrink
A one-time data load doubled a data file overnight, the load is done, the rows are deleted, and the file is now mostly empty space. The reflex — reach for DBCC SHRINKDATABASE and give the disk back — is a common way to hurt performance without meaning to. This post explains what shrinking does to your indexes, when it …
Read MoreDBCC DBREINDEX vs ALTER INDEX REBUILD in SQL Server
Open the SQL Agent job history on an instance that has been running for a decade and you will still find DBCC DBREINDEX in a nightly maintenance step, quietly doing its job. It works — which is exactly why nobody has touched it. But it has been deprecated for the better part of twenty years, it locks tables it does not …
Read MoreSQL Server Duplicate and Overlapping Index Detection Script
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 …
Read MoreSQL Server VLF Count Report: Virtual Log File Analysis
May 18, 2026 / · 7 min read · sql server virtual log files dbcc loginfo transaction log database maintenance sql scripts database administration log management performance sys.databases ·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 …
Read MoreSQL Server DBCC CHECKDB Last Run Date Report
Apr 17, 2026 / · 8 min read · sql server dbcc commands database maintenance database integrity DBCC CHECKDB DBCC DBINFO dba scripts database administration sql server monitoring integrity check sys.databases ·In busy SQL Server environments it is easy to lose track of which databases have had a recent DBCC CHECKDB and which have not. This script loops through all user databases, reads the last known good DBCC CHECKDB date from each one, and presents the results sorted from oldest to newest so you can spot gaps fast. Purpose …
Read More