Tag: SQL Server Administration
-
Troubleshooting Database Mirroring Issues in SQL Server
Database Mirroring is deprecated, but you will still see it in many production environments. It was officially marked deprecated in SQL Server 2012 and has remained in that state for well over a decade. In my own career as a DBA, it has been “deprecated” the entire time, yet still widely deployed and fully supported.…
Written by
-
Get Current Date & Time in SQL Server
Use GETDATE() (or SYSDATETIME() for more precision) for the current date and time, and CAST(GETDATE() AS date) for today’s date. There is no NOW() in SQL Server. Bring the habit over from MySQL or PostgreSQL and you get this: Msg 195 · Level 15 · State 10 ‘NOW’ is not a recognized built-in function name.…
Written by
-
Grant VIEW SERVER STATE in SQL Server
⚡VIEW SERVER STATE is the read-only permission behind the DMVs: sessions, requests, waits and plans. One query shows who has it and how they got it. Grant it with GRANT VIEW SERVER STATE TO [login]; If a grant seems to do nothing, a DENY is overriding it. What VIEW SERVER STATE Is For VIEW SERVER…
Written by
-
How to Right-Size SQL Server Database Files
Auto-growth is not the problem. Unplanned, reactive growth is. When a file is undersized SQL Server extends it repeatedly under load, every extension is a pause, and if those pauses land in the peak hour they show up as latency, I/O pressure and the occasional application timeout. Right-sizing is about making growth rare, predictable and…
Written by
-
SQL Server: ALTER DATABASE SET ENABLE_BROKER Taking a Long Time (Fix)
After a recent Availability Group failover, Database Mail stopped sending emails. On investigation, the underlying cause was Service Broker not being enabled on msdb, the system database Database Mail runs out of. Enabling it should be instant. Instead the statement sat there, and this is what it was waiting on. To confirm the status, I…
Written by
-
SQL Server: Ad hoc Update to System Catalogs is Not Supported (Fix)
Ad hoc update to system catalogs is not supported when RECONFIGURE runs: a leftover allow updates setting is the cause. The fix, and an instance-wide check.
Written by
-
How to Kill a SPID in SQL Server
⚡Find the head blocker, then KILL 69; with its session id. Whatever it had not committed rolls back, which can take longer than the work did and cannot be stopped. Watch it with KILL 69 WITH STATUSONLY;. In SQL Server, every connection to the database engine is assigned a Session Process ID, commonly known as…
Written by
-
How to Check Blocking SPIDs in SQL Server
Blocking is one of the most common causes of performance issues in SQL Server. When one session holds a lock on a resource and another session needs that same resource, the second session waits. If that wait persists, users experience slowness. Understanding how to quickly identify blocking SPIDs is a core DBA skill. This guide…
Written by
-
How to Check SQL Server Version
You need the exact version and build of a SQL Server instance: support is asking for it, a cumulative update is being planned, or an audit wants it in writing. SQL Server exposes it in several places, and they do not all answer the same question, so this post covers each one and when to…
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
- 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)