SQL Server Backup Compression: Enable and Verify
Apr 17, 2026 / · 7 min read · sql server backup recovery backup compression sp_configure msdb sql scripts database administration maintenance scripts ·Backup compression reduces the on-disk size of SQL Server backup files and can significantly shorten backup duration by reducing the amount of data written to disk. This post shows how to enable compression at the server level, verify the setting is active, and confirm compression ratios from backup history using 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 ·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 Find Orphan Users Script
Apr 17, 2026 / · 7 min read · sql server security orphan users sys.database_principals sys.server_principals sp_change_users_login database administration sql scripts security audit login management ·Orphaned database users are a common problem after database restores, server migrations, or login deletions. A database user becomes orphaned when its SID does not match any server-level login SID. This script queries sys.database_principals and sys.server_principals to find every orphaned user in a database, and shows …
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 Long-Running Queries: Find Active Sessions
Apr 12, 2026 / · 6 min read · sql server performance monitoring sql scripts sys.dm_exec_requests sys.dm_exec_sql_text blocking wait types database administration active sessions ·Find Active Long-Running Queries in SQL Server This script queries sys.dm_exec_requests and sys.dm_exec_sql_text to show all currently executing queries on the SQL Server instance, sorted by how long they have been running, along with CPU time, I/O activity, blocking status, and wait type information. Purpose and …
Read MoreSQL Server Agent Job Failure History Report
Apr 11, 2026 / · 8 min read · sql server sql server agent msdb sql scripts database administration job monitoring maintenance scripts reporting sysjobs sysjobhistory ·Report SQL Server Agent Job Status and Failure History This script queries the SQL Server Agent job history stored in msdb to produce a detailed report of each job's most recent run status, failure and success counts over the last 60 days, total lifetime run counts, and job step information including subsystem type and …
Read MoreKill SQL Server Sessions with Targeted Filters Using KILL and dm_exec_sessions This article covers a practical T-SQL script that kills one or more SQL Server sessions (SPIDs) while giving you precise control over which sessions are targeted. The script uses sys.dm_exec_sessions to query active sessions and a cursor to …
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 MoreSQL Server User Permissions and Role Memberships
Audit SQL Server Database User Permissions and Role Memberships This script queries the SQL Server system catalog to produce a complete audit of database-level permissions, covering direct object grants to users, permissions inherited through database roles, and permissions granted to the public role — all in a single …
Read MoreSQL Server Search Stored Procedure and View Text
Apr 9, 2026 / · 6 min read · sql server sql scripts sys.sql_modules sys.objects stored procedures views database administration object search maintenance scripts schema management ·Search Stored Procedure and View Definitions in SQL Server This script searches the text of stored procedures, views, functions, and triggers in the current database using sys.sql_modules, returning any programmable object whose name or definition contains a given keyword. Purpose and Overview Finding which stored …
Read More