DBA Scripts: The Complete Guide

Part of the DBA-Tools Project.


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 ten topic pillars, 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.


The Ten Pillars, One Line Each

🗄️
Server Inventory
What this server is: version, hardware, configuration, licensing, and what it’s connected to.
🔐
Security
Who can do what, what’s actually happening at the login layer, and what’s missing entirely.
💾
Backups and Recovery
Coverage, integrity, encryption, and restore readiness.
💽
Storage and Capacity
Disk, database, and filegroup free space, plus growth trend forecasting.
🟢
High Availability
Always On, mirroring, failover clustering, and replication, across four technologies.
🔒
Blocking and Locking
Who’s blocking whom, right now and historically.
🧩
Index Maintenance
Fragmentation, missing indexes, unused indexes, and duplicate coverage.
SQL Agent and Jobs
What’s scheduled, whether it’s succeeding, and whether it’s slowing down.
Query and Performance Tuning
What’s actually slow, and why.
🔍
Extended Events Tracing
Capturing evidence live when the DMV snapshot isn’t enough.

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


What Makes This Series Different

Every script post in this series follows the same shape on purpose: the real script (not a snippet), a genuine run against a live SQL Server instance with real captured output, an honest account of what a clean result looks like versus what a real finding looks like, and links forward and backward to the scripts that answer the next logical question. Several posts in this series exist specifically because writing the explanation surfaced a real bug in the script itself, DMV columns that didn’t exist, ambiguous joins, wrong catalog view references, fixed and documented, not just described.

That’s the standard: every script here has actually been run, not just written.


Summary

Ten pillars, one narrative on top of them: start with Server Inventory and Security on any unfamiliar server, confirm Backups and Recovery before you touch anything, then work outward toward whichever specific question brought you here. Bookmark this page as the starting point, 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 *