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 / · 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 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
Before sys.dm_db_index_physical_stats existed, checking fragmentation across a database meant looking up every user table's object ID and running DBCC SHOWCONTIG against each one individually. This script closes that gap for the sysobjects-based era of SQL Server administration: it queries sysobjects for every table of …
Read More