SQL DBA Blog: Home

  • How to Add Columns to Tables in SQL Server

    Adding a column is one line of T-SQL, and on most tables it finishes at once. The incidents come from two places: an ALTER TABLE that waits for a schema lock and blocks every query that arrives behind it, and a default value that makes SQL Server rewrite every row. This post covers the safe…

    Read More


  • How to Restore a Database in SQL Server

    Restoring a database in SQL Server is a core DBA task. Whether you’re responding to an incident, performing disaster recovery testing, migrating data, or rebuilding an environment, restores need to be predictable, repeatable, and verifiable. This post walks through restoring a database using both T-SQL and SQL Server Management Studio, along with the checks that…

    Read More


  • Why Is the Database in “In Recovery” Mode?

    Seeing a database stuck in Recovery mode usually happens at the worst possible time. It often appears after a restart, a restore, or an unexpected shutdown, and the immediate question is always the same: Is this normal, or do I need to intervene? This post explains what recovery mode actually means, how to tell whether…

    Read More


  • DBA Scripts: Get Database Mail and xp_cmdshell Configuration

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Security 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…

    Read More


  • 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.…

    Read More


  • 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…

    Read More


  • 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…

    Read More


  • 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…

    Read More


  • DBA Scripts: Get Last Database Backup Times

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.Related pillar: 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,…

    Read More


  • 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 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…

    Read More