SQL DBA Blog: Home

  • Using PowerShell to Get Last SQL Failover Time

    When reviewing availability events on SQL Server, one of the first questions is often: Did the cluster move, and when? This post shows how to use PowerShell to retrieve the last Windows Failover Cluster role movement for a SQL Server instance by querying cluster event logs. It’s a fast, reliable way to confirm node-level failovers…

  • Enabling TCP Connections in SQL Server

    TCP/IP must be enabled in SQL Server for remote connections to work. If it’s disabled, applications can’t connect; even if authentication, ports, and firewall rules are all correct. This post shows two reliable ways to enable TCP connections in SQL Server: Both approaches require a service restart before changes take effect. When You Need to…

  • Track Database Growth Events Over Time in SQL Server

    SQL Server’s default trace captures database and log file growth events, but it’s short-lived. Once the trace rolls over or the instance restarts, that history is gone. If you want to understand growth patterns over time, react less to disk alerts, and stop guessing which databases are mis-sized, you need to store those events somewhere.…

  • How to Show Line Numbers in SSMS

    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 them by default, which is why many guides still focus on “turning them on”.…

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

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

  • Script: List Sysadmin Role Members

    This script returns all logins that are members of the sysadmin fixed server role. It includes login type, whether the login is disabled, and default database information. This is commonly used during security reviews, onboarding and offboarding checks, and when validating privileged access in production environments. The Script Example Output The result set shows one…

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

  • Script: Check xp_cmdshell, CLR & Database Mail Configuration

    This script checks whether xp_cmdshell, CLR integration (including CLR strict security), and Database Mail are enabled on the instance. These features expand SQL Server’s capabilities beyond pure database operations. While commonly used, they increase surface area and should be intentionally configured. This script is useful during security reviews, environment validation, or when inheriting a server.…

  • Database Cannot Be Opened – It Is in the Middle of a Restore

    You may see the following error when attempting to access a database during or after a restore operation: Database “[DatabaseName]” cannot be opened. It is in the middle of a restore. This message is easy to misinterpret, especially during incidents or maintenance windows.It does not indicate corruption or failure by itself. This error means the…