Break Down Buffer Pool Memory by Database
Jul 12, 2026 / · 8 min read · sql server sys.dm_os_buffer_descriptors buffer pool data cache memory database memory dmv performance monitoring scripts ·sys.dm_os_buffer_descriptors is the DMV that maps SQL Server's data cache down to the individual page level — one row per 8 KB page currently held in the buffer pool, tagged with the database_id and file_id it belongs to. Rolling those rows up with a simple GROUP BY database_id turns millions of individual page entries …
Read MoreMeasure 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 / · 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 MoreConfigure Database Mail and Send a Test Message
Jul 1, 2026 / · 12 min read · sql server database mail sp_send_dbmail sysmail_add_account_sp sysmail_event_log msdb sql server agent sys.configurations sys.databases sysmail_allitems administration scripts ·Database Mail is switched off on a new instance, and sp_send_dbmail cannot work until an SMTP account, a profile that holds it, and a grant that lets users send through that profile all exist in msdb. The script below enables the feature, builds those three objects, sends a test message, and reads the queue and the …
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 MoreList All Tables Across All Databases in SQL Server
Jun 29, 2026 / · 9 min read · sql server sys.databases sys.tables sys.schemas sys.partitions dynamic sql cross database catalog views table inventory sp_executesql administration metadata scripts ·A table inventory that spans every database on an instance cannot be answered from one database context, because the table catalog lives inside each database. The pattern below reads the database list from sys.databases, builds one INSERT ... SELECT per online user database against that database's sys.tables and …
Read MoreSystem-Versioned (Temporal) Tables in SQL Server
Jun 19, 2026 / · 8 min read · sql server temporal tables system versioning for system_time history table sys.tables sys.databases point in time query data audit catalog views database structure metadata scripts ·Every UPDATE and DELETE on a system-versioned table leaves a queryable copy of the previous row, with no triggers and no hand-built audit table. SQL Server records the period each row version was valid and answers point-in-time questions through a single FOR SYSTEM_TIME clause. The catalog view sys.tables lists which …
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
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 Moresp_pkeys and Primary Key Metadata in SQL Server
Jun 16, 2026 / · 7 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 More