Author: Peter Whyte
-
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
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 or twenty databases, gut feeling is not an answer. You need the actual read/write numbers, per database, with the latency…
Written by
-
DBA Scripts: Get Wait Statistics
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 diary of where time goes, and reading them is the quickest way to find out…
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
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 takes forever. The usual cause is worker thread starvation: SQL Server has run out of threads to assign to incoming…
Written by
-
Get Database File Names and Paths in SQL Server
⚡Run the query, then read the growth column first. A percentage step is the one to change today. After that, look for a data file and its log on the same drive, and any number in max_size_mb: a cap stops the file with free space still on the disk. A disk is filling up, a…
Written by
-
DBA Scripts: Get SQL Agent Job Overview
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 can be hard to tell whether a job has been failing for a day or for 3 months. A job…
Written by
-
DBA Scripts: Get Services Information
A SQL Server instance is really a handful of Windows services working together, and it is surprisingly common for one of them to be quietly misconfigured. The SQL Server Agent service set to Manual startup instead of Automatic. A service running under an account nobody can account for. The Full-Text service left Disabled that nobody…
Written by
-
How to Increase Maximum Characters Displayed in SSMS
⚡Tools → Options, search for “results to text”, and raise Maximum number of characters displayed in each column. Then open a new query window. The default is 256, and output past it is cut off without a warning. By default, SQL Server Management Studio limits the number of characters displayed per column when using Results…
Written by
-
Applying Data Retention Safely in SQL Server
Data retention in SQL Server usually means deleting old data in a controlled and repeatable way. That might be driven by compliance requirements, table growth that’s starting to hurt performance, SQL Server Express size limits, or simply keeping log and audit tables under control. Whether this is a one-off cleanup or a permanent maintenance task,…
Written by
- Tune a Slow Query With Copilot in SSMS
- xp_readerrorlog: Read the SQL Server Error Log with T-SQL
- Cannot Drop Database Because It Is Currently in Use (Error 3702)
- Could Not Drop Login Because the User Is Currently Logged In (Error 15434)
- Set a Maximum Database File Size in SQL Server (MAXSIZE)
- SQL Server Activity Monitor in SSMS (and the Performance Dashboard)
- Backups & Recovery (18)
- DBA Scripts (154)
- High Availability (HA) (13)
- Installation & Configuration (60)
- Maintenance (25)
- Migration & Upgrades (14)
- Monitoring (10)
- Performance Tuning (38)
- Security (Encryption & Permissions) (25)
- Storage & Capacity (18)
- T-SQL Fundamentals (17)
- Troubleshooting (108)
- Wait Types (236)