This repository contains DatabaseHealthPerformanceReport.sql, a comprehensive T-SQL diagnostic script that generates a full health and performance profile of a SQL Server database. It is designed as a one-stop, read‑only reporting tool for DBAs, SQL Developers, data engineers, and anyone who needs fast visibility into how a database is behaving.
This report surfaces detailed information across multiple dimensions of SQL Server performance:
- Logical and physical file names
- File sizes, space used, and free space
- Growth settings and file types
- Row counts
- Data, used, and total size (MB)
- Highlights storage-heavy objects
- Seeks, scans, lookups, and updates
- Read vs write patterns
- Last usage timestamps
- Ideal for identifying unused or underused indexes
- Fragmentation percent
- Page counts
- Index types
- Helps determine rebuild vs reorganize strategies
- Estimated impact
- Equality, inequality, and INCLUDE columns
- Top 50 recommendations by estimated improvement
- Indexes with reads = 0
- High write / low read patterns
- Helps optimize storage and reduce overhead
- Average CPU, elapsed time, logical reads
- Query text snippet
- First/last execution timestamps
- Excellent for identifying performance bottlenecks
- Open sessions
- Blocking and wait types
- Current executing statement
- CPU and I/O details
-
Open the script in SQL Server Management Studio (SSMS) or your preferred SQL client.
-
Optionally specify a database context at the top of the file:
-- USE YourDatabaseNameHere; -- GO
-
Execute the script.
All sections run sequentially and return multiple result sets. -
Export results if needed:
- CSV, Excel, PDF, etc. via SSMS
- Useful for audits, documentation, and tuning sessions
Some sections rely on SQL Server DMVs and require:
VIEW SERVER STATEVIEW DATABASE STATE
If you lack these permissions, those sections will return limited or no data.
- Script is read-only and does not modify any data or objects.
- Uses both catalog views and DMVs.
- Fragmentation report uses SAMPLED mode for performance.
- Missing index DMV recommendations do not always equal optimal design — they are a starting point.
- Baseline database health checks
- Performance tuning sessions
- Pre‑migration analysis
- Identifying indexing improvements
- Developer onboarding to large/legacy databases
- Regular operational reporting
/
└── DatabaseHealthPerformanceReport.sql # Main T-SQL script
└── README.md # Documentation
Alex McAnnally
SQL Developer & Database Analyst
Last Updated: November 2025
Feel free to submit issues or pull requests with enhancements or suggestions.