Category: DBA Scripts
-
Script: I/O Usage by Database
This script returns total read and write activity per database based on file-level I/O statistics. It helps identify which databases are generating the most disk activity on the instance. This is commonly used during performance troubleshooting, storage pressure investigations, and workload analysis. The Script Example Output The result set shows one row per database, including…
-
Script: Check Worker Threads and Active Sessions
This script shows the current SQL Server worker thread count along with all active sessions and requests. It provides a live view of CPU usage, blocking, waits, running commands, and transaction activity. This is a practical script for performance troubleshooting when an instance appears busy, unresponsive, or under pressure. The Script Example Output The first…
-
Script: Top Wait Statistics
This script returns the top wait types since the last SQL Server restart or wait statistics clear, excluding common idle and background waits. It provides a quick high-level view of where the instance is spending time. This is often the first script run during performance investigations to identify whether the primary pressure is related to…
-
Script: Get SQL Server Agent Job Overview
This script returns an overview of all SQL Server Agent jobs on an instance, including job category, owner, whether the job is enabled, the last run start time, last run duration, and the next scheduled run time. It’s a practical check when reviewing inherited environments, validating job ownership, identifying disabled jobs, or confirming schedules after…
-
Script: Get SQL Server Services Information
This script returns details about the SQL Server and SQL Server Agent services running on an instance. It shows the service name, process ID, startup type, current status, service account, and whether instant file initialisation is enabled. This is a useful check when validating new builds, reviewing service accounts, or troubleshooting startup and permission-related issues.…
-
Script: Get Database Sizes and Free Space
This script returns file-level size and free space information for all databases on a SQL Server instance. It shows how much space is allocated, how much is used, and how much free space remains inside each data and log file. This is a go-to check when reviewing storage usage, investigating unexpected growth, or validating capacity…
-
Script: Estimate Backup and Restore Completion Time
This script shows the current progress and estimated completion time for running backup and restore operations. It’s intended to be used while an operation is already in progress, giving a clear view of how long it has been running and how much time is likely remaining. This is especially useful during incidents or maintenance windows…
-
Script: Check Backup Coverage Across All Databases
This script returns the most recent full, differential, and transaction log backup times for every database on a SQL Server instance. It’s designed as a quick sanity check to validate backup coverage, identify gaps, and confirm maintenance jobs are running as expected across an environment. The Script Example Output The result set shows one row…
-
Script: Get Instance Configuration Snapshot
This script returns a focused snapshot of instance-level configuration settings that DBAs commonly review when validating a server, inheriting an environment, or troubleshooting unexpected behaviour. It intentionally surfaces settings that have operational, security, or performance impact when misconfigured or left unchecked. The Script Example Output The result set shows the current values for key instance…
-
Script: Check MAXDOP Configuration
This script shows the current MAXDOP setting and helps you quickly validate whether it’s likely to be sensible for the server you’re connected to. It includes the configured MAXDOP value and core visibility information so you can make an informed call without digging through multiple places. The Script Example Output The first result set shows…