Configure 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 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 Moresp_pkeys: SQL Server Primary Key Discovery Script
Aug 9, 2025 / · 3 min read · sql server primary keys database administration scripts sysobjects sp_pkeys dynamic sql sysobjects sys.tables sys.key_constraints INFORMATION_SCHEMA.TABLE_CONSTRAINTS ·SQL Server Primary Key Discovery Script Using sp_pkeys and sysobjects Purpose This SQL Server script generates dynamic SQL statements that can be executed to discover primary keys across all user tables in a database. It's a powerful administrative tool that helps database administrators quickly identify primary key …
Read MoreGenerate DBCC SHOWCONTIG Commands for All SQL Server Tables
Generate DBCC SHOWCONTIG Commands for All User Tables in SQL Server 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 …
Read More