Author: Peter Whyte
-
Database Cannot Be Opened – It Is in the Middle of a Restore
🚨Part of the SQL Server Errors series, the exact messages and what actually causes them.In: Backup & Recovery You may see this error when trying to access a database during or after a restore: Msg 927 · Level 14 · State 2 Database ‘YourDb’ cannot be opened. It is in the middle of a restore.…
Written by
-
DBA Scripts: Check AG Replica Role and Synchronization State
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: High Availability Is Every Replica Actually Ready to Take Over A failover just happened or the AG dashboard has gone red, and you need to know which replica is primary now and whether every secondary is connected and in sync. Run this on…
Written by
-
Kill All User Sessions on a Database in SQL Server
When you need to drop, restore, or change database settings, active user sessions often get in the way. SQL Server will block these operations until all connections are cleared. In busy environments, waiting is rarely practical. If you arrived here from Msg 5030, the database could not be exclusively locked, or from a restore that…
Written by
-
DBA Scripts: Check Always On Availability Group Latency
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: High Availability How Far Behind Is Each Database, Really A readable secondary is serving stale data, commits on the primary have slowed, or a failover is about to depend on a replica you have not checked. Run this on the primary: it returns…
Written by
-
DBA Scripts: Get Last Database Backup Times
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Backup & Recovery Checking the last backup times is one of the first things worth doing when you sit down at a SQL Server instance, whether it’s one you’ve owned for years or one you inherited an hour ago. Before making changes, running…
Written by
-
DBA Scripts: Get Disk Space on SQL Server
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Storage & Capacity A SQL Server that runs out of disk stops taking writes, and depending on which volume filled up, that can mean suspended databases, a frozen transaction log, or failed backups at exactly the wrong moment. Disk space is the least…
Written by
-
Testing Remote Server Port Connectivity with PowerShell
An application cannot connect to SQL Server, and before anyone goes near a configuration file there is 1 question to settle: is the port reachable from this server, or is something in the path blocking it? ⚡The short version. Run Test-NetConnection -ComputerName <server> -Port 1433. TcpTestSucceeded : True and the port is open from here,…
Written by
-
DBA Scripts: Get Long-Running Queries
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Performance & Troubleshooting › Query & Performance Tuning When users report the application is slow, the first question is always the same: what is actually running right now? Not what ran an hour ago, not what the plan cache thinks is expensive on…
Written by
-
How to Check Listening Ports on Windows
An application cannot connect, and before you look at firewalls, DNS or logins you need one fact: is SQL Server listening on this machine, and on which port? Ask Windows which ports the sqlservr process holds, then ask SQL Server which port it bound at startup. If the two agree and the client still fails,…
Written by
-
DBA Scripts: Get Missing Indexes
🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Index Maintenance Every time SQL Server builds an execution plan that could have been improved with a better index, it makes a note of it. Those notes accumulate in memory and are queryable through the sys.dm_db_missing_index_* DMVs, and combined…
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)