DBA Scripts: The Complete Guide

🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.

Where to Start With This Series

The DBA Scripts series on this blog covers backups, blocking, indexes, SQL Agent, query performance, extended events tracing, server inventory, and security, organized into eight areas of the job, fourteen pillars in total, each one tying together a cluster of scripts that answer a related set of questions. That’s a lot of ground, and “where do I actually start” is a fair question whether you’re new to this site or you’ve been inheriting an unfamiliar server every few months for years.

This post is the map above the maps: not a script itself, and not a pillar, but the guide to the pillars. It’s organized around the moments a DBA actually reaches for tooling, not around the categories the scripts happen to live in, so you can start from your actual situation rather than browsing a list.



Eight Areas, Fourteen Pillars

Start with the area that matches your situation, each one opens onto its pillars and the scripts underneath.

🗄️
Server & Configuration
What this server is and how it got that way: inventory, hardware, configuration, licensing, installation, and patching.
💽
Storage & Capacity
Disk, database, and filegroup free space, plus growth trend forecasting.
💾
Backup & Recovery
Coverage, integrity, encryption, and restore readiness.
🟢
High Availability
Always On, mirroring, failover clustering, and replication, across four technologies.
Performance & Troubleshooting
What’s actually slow and why: blocking, query tuning, live event tracing, and the collectors that baseline it all first.
🔐
Security
Who can do what, what’s actually happening at the login layer, and what’s missing entirely.
Maintenance & Automation
Scheduled jobs, index health, and generated maintenance DDL: what’s running and whether it’s still working.
🔁
Migration & Deployment
Logins, jobs, user mappings, linked servers, and restore-with-move DDL for a migration.

Start Here: Inheriting an Unfamiliar Server

If you’ve just been handed a server you’ve never seen before, this is the order that builds understanding fastest, each step assumes the last:

  1. Server Inventory first, always. Version, hardware, configuration, and licensing are the baseline everything else gets read against. Skipping this means every later finding is read without context.
  2. Security second. Who has privileged access, what’s actually happening at the login layer, and what auditing infrastructure does or doesn’t exist. This is the review most likely to surface something that changes your priorities for everything after it.
  3. Backups and Recovery third. Before you touch anything or tune anything, confirm you could actually recover this server if something went wrong during the review itself.
  4. Storage and Capacity fourth. Confirm there’s actually room to keep operating, disk, database, and filegroup free space, before anything else on this list.
  5. SQL Agent and Jobs fifth. What’s scheduled to run, whether it’s succeeding, and whether anything’s quietly getting slower. Maintenance jobs you didn’t know existed can explain a lot of otherwise-mysterious server behavior.
  6. Blocking and Locking, Index Maintenance, and Query and Performance Tuning last, once the foundation is confirmed sane, these three answer “is it fast enough and why not,” in whichever order matches the specific complaint you’re chasing.

By the Question You’re Actually Asking

Sometimes you don’t need the full review, you have one specific problem right now. Here’s the fast path for the moments that come up most.

“Is this server going to lose data?”
Backups and Recovery, specifically Backup Coverage and Suspect Pages and Integrity Checks
“Why is everything slow right now?”
Blocking and Locking first to rule out active blocking, then Query and Performance Tuning
“Did we just get compromised, or could we be?”
Security, start with Sysadmin Members and Login Security Audit
“A maintenance job silently stopped working, what else did?”
SQL Agent and Jobs
“We’re migrating or upgrading, what will break?”
Server Inventory, specifically Edition Feature Usage and Linked Servers
“I need to catch something live, the DMV snapshot already missed it”
Extended Events Tracing
“Queries feel slower than they used to, generally”
Index Maintenance, index health degrades quietly and this is the most commonly overlooked routine check
“Are we about to run out of room?”
Storage and Capacity, start with Database Free Space Summary and Database Growth Risk and Forecast
“Would a failover actually work right now?”
High Availability, start with AG Failover Readiness and Readable Secondary Usage

Jump Straight to a Popular Script

The most-reached-for scripts in the series, and the question each one answers:


Troubleshooting a Specific Error or Symptom

Not every question fits the pillar structure above. Some things are a specific error message or an active incident, not a survey of a whole area. A parallel Troubleshooting series covers those: step-by-step diagnostic workflows for a live problem, each one still linking back to the real scripts in the pillars above rather than duplicating them.

Browse All Troubleshooting →


Related script: Install and Update SSMS via PowerShell


What Makes This Series Different

Every script post follows the same shape on purpose: the real script, a genuine run against a live SQL Server instance with captured output, what a clean result looks like versus a real finding, and links to the scripts that answer the next logical question. Several posts exist because writing the explanation surfaced a real bug in the script itself, fixed and documented, not just described.

The standard: every script here has actually been run, not just written.

Summary

Start with Server Inventory and Security on any unfamiliar server, confirm Backups and Recovery before you touch anything, then work outward toward the question that brought you here. For a specific error it’s the Troubleshooting series, for the tool itself the SSMS guide. Bookmark this page, and the pillar you land on next will link you the rest of the way.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *