Configure 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 MoreList All Tables Across All Databases in SQL Server
Jun 29, 2026 / · 8 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 DBCC CHECKDB: Complete 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 ·Most advice about DBCC CHECKDB stops at "run it weekly," but the command has options that change what it checks, how long it takes and what it can do to your data. The check options, a script that runs the command against every online user database, and the three repair levels all matter here, including why …
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 Database File Space Usage Report
May 17, 2026 / · 8 min read · sql server sys.master_files sys.dm_os_volume_stats database files disk space monitoring sql scripts database administration fileproperty sys.database_files sys.databases ·Running out of space inside a data or log file halts SQL Server transactions immediately — and discovering that a volume is full only after an outage is too late. This script queries sys.master_files and sys.dm_os_volume_stats across every online database on the instance to report each file's allocated size, space …
Read MoreSQL Server: Find Databases With No Recent Backup
Apr 19, 2026 / · 6 min read · sql server backup recovery msdb monitoring database administration sql scripts backup audit sys.databases ·Finding databases that have not been backed up recently is one of the most important checks a DBA can run. A database that grows unnoticed without a backup is a data loss event waiting to happen. This script queries msdb.dbo.backupset against sys.databases to surface any online user database with no full backup in the …
Read MoreSQL Server DBCC CHECKDB Last Run Date Report
Apr 17, 2026 / · 7 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 ·Running DBCC CHECKDB 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 DBCC CHECKDB date from each one, and …
Read MoreSQL Server Backup History: Duration and Size Report
Apr 13, 2026 / · 6 min read · sql server backup recovery msdb sql scripts database administration backup monitoring maintenance scripts reporting sys.databases backupset ·Query Backup Duration and File Size from SQL Server History This script queries SQL Server's msdb backup history to report the backup type, start and finish time, duration in minutes, and file size in both megabytes and gigabytes for every backup across all user databases on the server. Purpose and Overview Knowing …
Read MoreSQL Server Backup Status Report: All Databases
Check SQL Server Backup Age Across All Databases This script queries the SQL Server backup history catalog to report the most recent full, differential, and transaction log backup for every database, including how many hours and minutes ago each backup completed. Purpose and Overview Database backups are your last line …
Read More