SQL Server CPU Utilization History Report
SQL Server records CPU utilization data internally every minute and stores the last 256 readings in a ring buffer. This T-SQL script reads that buffer to produce a CPU history report showing SQL Server CPU usage, other process CPU usage, and total server CPU load — without requiring any external monitoring tool. …
Read MoreSQL Server DBCC CHECKDB Last Run Date Report
Apr 17, 2026 / · 7 min read · sql server dbcc commands database maintenance database integrity DBCC CHECKDB DBCC DBINFO dba scripts database administration sql server monitoring integrity check ·Running DBCC CHECKDB on every database is one of the most important tasks for a SQL Server DBA. But in busy environments it is easy to lose track of which databases have been checked recently and which have not. This script loops through all user databases, reads the last known good DBCC CHECKDB date from each one, and …
Read MoreSQL Server TempDB Usage and Contention Report
Apr 17, 2026 / · 7 min read · sql server tempdb dm db session space usage dm exec sessions dm exec requests dm exec sql text monitoring dba scripts space usage contention performance ·TempDB is a shared system database used by every session in SQL Server. When TempDB space grows or performance slows, it can be difficult to know which sessions are responsible. This script queries sys.dm_db_session_space_usage to show a clear breakdown of TempDB consumption per session, including the current SQL …
Read MoreSQL Server Point-in-Time Restore with STOPAT
Apr 5, 2026 / · 8 min read · sql server restore backup recovery transaction log msdb database maintenance DBA scripts point in time restore sys.databases ·Recover a SQL Server Database to a Specific Point in Time SQL Server's RESTORE LOG ... WITH STOPAT lets you roll a database back to any exact moment covered by your backup chain. This guide walks through querying backup history in msdb, executing the restore sequence, and verifying the result. Purpose and Overview Data …
Read MoreSQL Server Blocking Detection: Find Blocked Sessions
Blocking in SQL Server occurs when one session holds a lock that another session needs, causing the second session to wait. This T-SQL script queries the dynamic management views to show all currently blocked sessions, the blocking session, wait type, wait duration, and the SQL text involved. Purpose and Overview When …
Read MoreSQL Server Missing Indexes Report: dm_db_missing_index
Feb 28, 2026 / · 6 min read · sql server missing indexes performance dm db missing index details dm db missing index group stats index tuning dba scripts query optimization sys.dm_db_index_usage_stats sys.dm_db_missing_index_details sys.dm_db_missing_index_group_stats sys.dm_db_missing_index_groups sys.index_columns sys.indexes ·SQL Server tracks index recommendations automatically as queries execute, storing them in the missing index DMVs. This T-SQL script queries those views to produce a ranked report of missing indexes, ordered by the estimated improvement they would provide, along with a ready-to-run CREATE INDEX statement for each …
Read MoreSQL Server Wait Statistics Report: dm_os_wait_stats
Feb 27, 2026 / · 6 min read · sql server wait statistics performance dm os wait stats wait types bottleneck analysis dba scripts performance tuning sys.dm_os_wait_stats sys.dm_os_waiting_tasks ·Wait statistics are one of the most reliable ways to identify performance bottlenecks in SQL Server. This T-SQL script queries sys.dm_os_wait_stats, filters out background and idle wait types that do not indicate real problems, and ranks the remaining waits by their percentage of total wait time. Purpose and Overview …
Read MoreSQL Server: Find Tables with Clustered Indexes for Rebuild
SQL Server Query to Identify Tables with Clustered Indexes for Rebuilding Database administrators frequently need to perform maintenance operations on clustered indexes to optimize database performance. This SQL Server query provides a quick and efficient way to identify all user tables that contain clustered indexes, …
Read MoreSQL Server DBCC DBREINDEX with Timing: Index Maintenance
Aug 5, 2025 / · 4 min read · sql server database maintenance performance tuning dbcc commands index optimization dba scripts database administration sql scripts DBCC DBREINDEX sysobjects ·SQL Server DBCC DBREINDEX Script with Timing - Database Maintenance Guide Database maintenance is a critical aspect of SQL Server administration, and index rebuilding plays a vital role in maintaining optimal database performance. This comprehensive guide explores powerful DBCC DBREINDEX scripts that include timing …
Read More