SQL Server DBA Scripts & Tools
dba-tools is the toolkit I use as a working SQL Server DBA, free and open on GitHub. Copy/paste scripts for the day-to-day, a one-command health check, and an AI assessment that reviews the whole server with you.
Quick Access
Repo Areas
📋 Copy/Paste First
170+ production-safe SQL scripts. Open one, paste it into SSMS, run it. No install, no parameters, no magic variables.
🩺 Health Check
39 diagnostic scripts run in a single command, saved as CSVs, then a rules review flags CRITICAL / WARNING / INFO findings.
🤖 AI Assessment
The flagship. An AI reads the whole collection, correlates findings into root causes, and writes a prioritized report.
Quick Start
Clone the repo and run the setup script. It checks prerequisites, installs the SqlServer module if missing, and verifies the connection. Pass or fail, it tells you exactly what to do next.
git clone https://github.com/peterwhyte-lgtm/dba-tools
cd dba-tools
.\Initialize-Environment.ps1
To target a remote or named instance instead:
.\Initialize-Environment.ps1 -ServerInstance PROD01\SQL2025
Once setup passes, the server is saved for the session and every script picks it up automatically. Everything is read-only by default, and every script header states the permissions it needs and what it touches.
🤖 The Health Check, Reviewed by AI
The flagship workflow. A collection runs 39 diagnostic scripts against an instance (backups, waits, blocking, memory, disk, security surface area) and saves every result as a CSV. A rules review turns those into deterministic findings. Then the AI assessment reads the whole collection and does what fixed thresholds can’t: it correlates findings across the outputs into root causes and writes a prioritized report with evidence and a fix for each issue.
It’s a second reviewer that has read every output, doesn’t get tired, and surfaces the blindspots you’d miss at 2am. Nothing is sent to any AI until you run the assessment step yourself.
A 30-second run: terminal command, web UI output, then the same script in SSMS.
Three commands take a server from no idea to a written assessment:
# 1. Collect
.\powershell\reporting\Invoke-HealthCheckCollection.ps1 -ServerInstance PROD01\SQL2025
# 2. Rules review
.\powershell\reporting\Review-HealthCheckOutput.ps1
# 3. AI assessment
.\powershell\reporting\Invoke-AiAssessment.ps1
What’s Inside
Three Ways to Run It
1. SQL in SSMS
Copy any script from the repo straight into SSMS, run it, and get results immediately. This is the core toolkit path and needs nothing else installed.
2. PowerShell
Run the same scripts by name from terminal, for example .\run.ps1 Get-WaitStatistics, and export output to CSV for analysis and reporting.
3. The Web UI
A local dashboard where collections are viewed and verified: health scorecard, security drill-down, disk capacity, AI reports, and live incident triage.
Script Articles
The scripts worth explaining get their own articles: what the script returns, when to use it, and the full script ready to copy. Organized into eight areas of the job, each one opening onto its own pillar page or pages:
📁 Server & Configuration
- Server Inventory (hub)
- Get SQL Server Instance Configuration Snapshot
- Check MAXDOP Configuration in SQL Server
- Installation and Patching (hub)
- Pre-Install and Post-Install Checks
- Install and Configure SQL Server
- Uninstall SQL Server
- Install/Update SSMS via PowerShell
- Uninstall SSMS via PowerShell
- Patch SQL Server and Check Status
💽 Storage & Capacity
- Storage and Capacity (hub)
- Check Disk Space on SQL Server
- Get Database Sizes and Free Space
- Get Database Free Space Summary
- Get Filegroup Space
- Get Database Growth Risk and Forecast
- Get Log Reuse Waits
- Get Autogrowth History
- Get Temp DB Hotspots
💾 Backup & Recovery
- Backups and Recovery (hub)
- Check Backup Coverage Across All Databases
- Get Backup Chain Integrity
- Get Recovery Model Audit
- Generate Backup and Restore Scripts
🟢 High Availability
⚡ Performance & Troubleshooting
- Query and Performance Tuning (hub)
- Wait Types Library (hub), 367 wait types documented, plus the ranking script itself
- Identify Long-Running Queries
- Blocking and Locking (hub)
- Get Blocking Sessions
- Get Deadlock Summary
- Extended Events Tracing (hub)
- Collectors and Baseline Infrastructure (hub)
- Collect Blocking and Deadlock Events
- Collect Performance Baselines
- Collect Capacity and Temp DB Baselines
- Collect Health and Configuration Baselines
- Generate Collector Alerts
🔒 Security
🛠️ Maintenance & Automation
- SQL Agent and Jobs (hub)
- Get SQL Agent Job Failures
- Index Maintenance (hub)
- Identify Missing Indexes
- Get Index Fragmentation
- Maintenance Job Framework (hub)
- Generate Backup Jobs
- Generate Database Integrity and Housekeeping Jobs
- Generate Index Maintenance Jobs
🔁 Migration & Deployment
Production DBA Daily Scripts
Day-to-day production shortlist. These are the scripts to grab first when triaging activity, checking capacity, validating resilience, and getting through change windows safely.
Operations and Triage
Storage and Capacity
Resilience and Security
Grab the Toolkit
Free and open source. Every script came from a real situation: an incident, a migration window, or a routine check that needed to be fast and safe.
Key Links
DBA Scripts: The Complete Guide
Query and Performance Tuning
High Availability
Security
Storage and Capacity
Installation and Patching
Backups and Recovery
Blog Categories
- Backups & Recovery (5)
- DBA Scripts (147)
- High Availability (HA) (7)
- Installation & Configuration (16)
- Maintenance (4)
- Migration & Upgrades (1)
- Monitoring (6)
- Performance Tuning (5)
- Security (Encryption & Permissions) (3)
- T-SQL Fundamentals (11)
- Troubleshooting (23)
- Wait Types (235)
Latest Posts
- Compatibility Levels: What Actually Changes When You Bump It
- SQL Server Management Studio (SSMS): The Complete Guide
- SQL Server Collation: Case Sensitivity and the Cross-Database Trap
- SQL Server Isolation Levels (and When to Reach for RCSI)
- DBA Scripts: Get Database Summary
- DBA Scripts: Get Database Inventory
Blog Tags
Access (4) Always On Availability Groups (4) Auditing (7) Backups (6) Blocking (4) Blocking Locking (6) Collectors (7) Database Backups & Recovery (8) Database Backups and Recovery (5) Database Maintenance (7) DBA Tools (24) Disk Space (5) Extended Events (8) Features (6) High Availability (6) Indexes (7) Installation (7) Inventory (8) Jobs (3) Maintenance (7) Migration (15) Monitoring (27) Performance (21) Performance Troubleshooting (9) PowerShell (4) Query Behaviour (5) Security (10) SQL Agent (5) SQL Scripts (17) SQL Server Administration (10) SQL Server Configuration (7) SQL Server Errors (5) SQL Server High Availability (4) SQL Server Internals (3) SQL Server Management Studio (SSMS) (6) SQL Server Monitoring (7) SQL Server Networking (9) SQL Server Security (7) Storage and Capacity (7) T-SQL (10) Temp DB (3) Tracing (7) Transaction Logs (4) Troubleshooting (24) Windows Server (4)