Tag: SQL Scripts
-
DBA Scripts: Get Database Mail and xp_cmdshell Configuration
An audit or a pen test report asks whether xp_cmdshell is on, or alert emails stopped arriving and you need to know whether Database Mail is even switched on. This script answers both in one result, alongside CLR, force encryption and live NTLM sessions. Why Database Mail and xp_cmdshell Matter Each of these settings expands…
Written by
-
DBA Scripts: Check AG Replica Role and Synchronization State
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 the primary: it reads each replica’s role, connection state, synchronization health and last connection…
Written by
-
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 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
-
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
-
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
-
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 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
-
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
- 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)