Measure Disk I/O Performance per Database File
Jul 3, 2026 / · 8 min read · sql server sys.dm_io_virtual_file_stats sys.master_files disk io io stall disk latency performance database files dmv monitoring scripts ·I/O latency is where disk bottlenecks hide. SQL Server accumulates every millisecond of file-level read and write wait in sys.dm_io_virtual_file_stats — one row per database file, reset at each service restart. Joining that DMV to sys.master_files replaces raw file IDs with physical paths and file types, and dividing …
Read MoreDetect Suspect Database Pages with msdb.dbo.suspect_pages
Jul 2, 2026 / · 9 min read · sql server suspect pages msdb database corruption page corruption dbcc checkdb integrity check maintenance storage error scripts ·Storage errors do not always surface as immediate failures. When SQL Server encounters an 823, 824, or 825 error reading or writing a database page, it records the offending page in msdb.dbo.suspect_pages — a system table that accumulates page-level I/O failures across service restarts. Querying this table is the …
Read MoreConfigure Database Mail and Send a Test Message
Jul 1, 2026 / · 11 min read · sql server database mail sp_send_dbmail sysmail_add_account_sp sysmail_event_log sysmail_mailitems sysmail_account sysmail_profile msdb sql server agent administration scripts ·Database Mail ships disabled; enabling it and wiring up an SMTP account, a profile, and a public principal grant are the steps that stand between a fresh SQL Server instance and sp_send_dbmail working reliably. The configuration script below executes all four setup calls inside msdb, fires a test message, and queries …
Read MoreApply Row and Page Compression to Tables and Indexes
Jun 30, 2026 / · 10 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 ·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. sys.dm_db_index_physical_stats joined to sys.partitions surfaces every …
Read MoreList All Tables Across All Databases in SQL Server
Jun 29, 2026 / · 11 min read · sql server sys.databases sys.tables sys.schemas dynamic sql cross database catalog views table inventory sp_executesql administration metadata scripts ·A cross-database table inventory is one of the most common ad hoc requests in any SQL Server environment — and one of the few queries that cannot be answered by staying inside a single database context. sys.databases exposes every online database on the instance; three-part name references to sys.tables inside dynamic …
Read MoreSystem-Versioned (Temporal) Tables in SQL Server
Jun 19, 2026 / · 6 min read · sql server temporal tables system versioning for system_time history table sys.tables point in time query data audit catalog views database structure metadata scripts ·Every UPDATE and DELETE on a system-versioned table leaves behind a complete, queryable history of the previous row — automatically, with no triggers and no audit-table plumbing. SQL Server records the period each row version was valid and answers point-in-time questions through a single FOR SYSTEM_TIME clause. This is …
Read MoreSQL Server Database Schema and Data Dictionary Queries
Jun 18, 2026 / · 6 min read · sql server information_schema data dictionary database schema metadata sys.objects sys.columns sys.sql_modules catalog views documentation database structure ansi standard scripts ·Documenting a database starts with a data dictionary: every table, every column, its data type, length, nullability, and default. SQL Server exposes this through the ANSI-standard INFORMATION_SCHEMA views, which produce a portable schema report that reads almost like English and runs unchanged on other ISO-compliant …
Read MoreHow to Update Statistics in SQL Server
A query that ran in milliseconds last month now scans a million rows and spills to tempdb. Nothing changed in the code — but the data grew, and the statistics the optimizer relies on went stale, so its row estimates drifted far from reality and it chose a bad plan. Refreshing statistics is the fix, and knowing how and …
Read Moresp_pkeys and Primary Key Metadata in SQL Server
Jun 16, 2026 / · 6 min read · sql server sp_pkeys sys.key_constraints sys.index_columns sys.columns sys.types sys.tables sys.objects sys.schemas information_schema primary keys catalog views metadata database structure scripts ·Which columns make up a table's primary key, and in what order are they declared? For a single table, the system stored procedure sp_pkeys answers in one line; for a database-wide inventory, the catalog views behind it give you full control. This post covers both, from the quick lookup to the complete metadata query. …
Read Moresysindexes vs sys.indexes: Legacy and Modern Catalog Views
Plenty of SQL Server scripts still in circulation read rowcnt and dpages straight out of sysindexes — a habit inherited from SQL Server 2000, where that table was the canonical place to find row counts and page totals. The object survives only as the sys.sysindexes compatibility view, is flagged for removal, and …
Read More