Author: Peter Whyte
-
Get Last Database Restore Date and Time in SQL Server
Knowing when a database was last restored is useful during incident response, audits, and general environment validation. This is not about backup schedules or restore progress. It is one historical check that answers one question, when was this database last restored, and the query below answers it for every database on the instance. Show Last…
Written by
-
DBA Scripts: Get Index Fragmentation Across Databases
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Index Maintenance Reports and range scans have slowed over weeks, or you have just inherited a server and need to know whether anyone has been maintaining its indexes. This lists every index at 5% fragmentation or more in every…
Written by
-
DBA Scripts: Get User Permissions Audit
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Security The One Login You Actually Care About Right Now Off-boarding someone, or asked why one login can read a database it should not? Set @LoginName and run this. It returns one row for the server and one for every database the login…
Written by
-
Deleting Rows in Batches in SQL Server
A DELETE that removes hundreds of thousands of rows in one go is the one that fills the transaction log, locks the whole table and leaves everything else waiting. Delete in batches instead: small transactions whose log space can be reused, and a lock footprint other sessions can work around. Here is the loop, and…
Written by
-
DBA Scripts: Get Database IO Usage
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Performance & Troubleshooting › Query & Performance Tuning When a SQL Server is struggling and the usual suspects (CPU, memory, blocking) come back clean, the next question is always the same: which database is hammering the disks? On a busy instance hosting ten…
Written by
-
DBA Scripts: Get Wait Statistics
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Performance & Troubleshooting Every time a SQL Server session has to wait for something, a lock, a page from disk, a CPU slice, a memory grant, the engine records what it waited on and for how long. Those counters are the instance’s own…
Written by
-
TDE Restore Fails: Cannot Find Server Certificate (Error 33111)
A TDE database restore on another server fails with Msg 33111. Match the thumbprint in the message, create the certificate in master from its .cer and .pvk backup files, and the same restore goes through.
Written by
-
DBA Scripts: Get Worker Threads and Active Sessions
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Performance & Troubleshooting › Query & Performance Tuning There is a particular kind of SQL Server incident where the server is up, CPU looks fine, and yet new connections hang or time out. Applications report login failures, and even your own SSMS connection…
Written by
-
Get Database File Names and Paths in SQL Server
As a DBA, you regularly need to know where your database files live, how big they are, and how they’re configured to grow. Capacity planning, migration prep, new environment review, disk space incidents: they all start here. This script gives you a full picture of every user database file on the instance: physical path, drive…
Written by
-
DBA Scripts: Get SQL Agent Job Overview
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › SQL Agent & Jobs Most SQL Server instances end up with a handful of Agent jobs that quietly run backups, index maintenance, and monitoring collectors in the background. Nobody looks at them until something breaks, and by then it…
Written by
- SQL Server Row-Level Security: The Filter Does Not Stop Cross-Tenant Writes
- View the Definition of a Stored Procedure in SQL Server
- TempDB Is Full or Still Growing: Find What Is Using It, Right Now
- SQL Server Service Will Not Start: Error 17113, 17058, 1067 and Where the Real Reason Is
- How to Move TempDB Files in SQL Server
- RAND() vs NEWID() in SQL Server
- Backups & Recovery (17)
- DBA Scripts (151)
- High Availability (HA) (12)
- Installation & Configuration (49)
- Maintenance (25)
- Migration & Upgrades (14)
- Monitoring (9)
- Performance Tuning (37)
- Security (Encryption & Permissions) (20)
- Storage & Capacity (16)
- T-SQL Fundamentals (15)
- Troubleshooting (94)
- Wait Types (235)