SQL DBA Blog: Home

  • How to Show Line Numbers in SSMS

    🛠️Part of the SSMS Complete Guide, installing, configuring and fixing SQL Server Management Studio. In modern versions of SQL Server Management Studio, line numbers are enabled by default. If you are running SSMS 21 or newer, you will already see line numbers in query windows without changing anything. Older versions of SSMS did not enable…

    Read More


  • How to Add Columns to Tables in SQL Server

    Adding columns to tables in SQL Server is a routine task, but it is not always a harmless one. On small tables it is trivial. On large or business-critical tables, especially those involved in replication or heavy write workloads, it can introduce blocking, transaction log growth, or downstream latency if handled carelessly. This post walks…

    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 xp_cmdshell lets any login with EXECUTE permission on it run arbitrary operating system commands from inside SQL Server. It’s genuinely useful for a handful of legacy automation tasks, and it’s also one of the first things a penetration tester checks for, because…

    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. You may see this error when trying to access a database during or after a restore: Msg 927  ·  Level 14  ·  State 2 Database “[DatabaseName]” cannot be opened. It is in the middle of a restore. It is easy…

    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 An Availability Group only protects you if every secondary replica is actually connected, synchronized, and healthy at the moment you need it. A replica that quietly dropped its connection hours ago looks identical…

    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. This post shows a safe, deliberate, and review-first way to identify and kill all user sessions connected to a…

    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 Availability Group Replica State answers whether a replica is connected and generally healthy. It doesn’t answer the database-level question that actually matters during an incident: how much data is sitting in the send queue…

    Read More


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

    Read More