Author: Peter Whyte
-
DBA Scripts: Check Always On Availability Group Latency
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 every availability database on every replica with its send queue, redo queue and rates,…
Written by
-
DBA Scripts: Get Last Database Backup Times
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 maintenance, or troubleshooting an issue, you need to know whether a reliable recovery point actually…
Written by
-
DBA Scripts: Get Disk Space on SQL Server
Run Get-DiskSpace when a SQL Server volume is filling and you have SQL access but no RDP. It reports free and used space on database-file volumes, fullest first. Why Disk Space Matters SQL Server does not degrade gracefully when a volume fills. A full data volume means autogrow fails and inserts start throwing errors. A…
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 one 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 -Port 1433. TcpTestSucceeded : True and the port is open from here, so…
Written by
-
DBA Scripts: Get Long-Running Queries
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 average, but what is executing on the instance at this moment and how long it has been at it. This…
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
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 into a single ranked list they are one of the fastest wins in SQL Server performance tuning. The…
Written by
-
Get Last Database Restore Date and Time in SQL Server
A database holds data nobody expected, a refresh is said to have run last night, or an audit wants to know when production was last overwritten. The first fact to pin down is when the database was last restored, and msdb records it for every database on the instance. This is not about backup schedules…
Written by
-
DBA Scripts: Get Index Fragmentation Across Databases
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 online user database, in one result set, worst first across the server, so you can see where the…
Written by
-
DBA Scripts: Get User Permissions Audit
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 can open, with every role it holds there, nested roles and AD groups…
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)