Author: Peter Whyte

  • Testing Remote Server Port Connectivity with PowerShell

    Testing connectivity to remote server ports is a basic skill every DBA should have. Not just DBAs either — anyone running production systems needs to be able to answer one simple question quickly: Can this server actually reach that server on this port? This post shows two reliable ways to test whether a remote port…

  • How to Check Listening Ports on Windows

    When troubleshooting connectivity issues, it’s often not enough to test whether a remote port is reachable. You also need to know what is actually listening on a port locally, or whether anything is listening at all. This post focuses on the local side of the equation, what is listening on the machine itself and which…

  • Get Last Database Restore Date and Time in SQL Server

    Knowing when a database was last restored is useful during incident response, audits, and general environment validation. This is not about backup schedules or restore progress.It is a simple historical check that answers one question: When was this database last restored? This post shows a reliable way to retrieve the most recent restore date and…

  • Script: SQL Server User & Permissions Audit

    This script audits SQL Server users and permissions across all databases on an instance. It consolidates server-level logins, database users, Windows groups, and role memberships into a single result set. It is useful during security reviews, access audits, migrations, or when validating permissions after changes. The Script Example Output The result set shows consolidated role…

  • Deleting Rows in Batches in SQL Server

    Deleting large volumes of data from a SQL Server table looks simple, but it can cause real problems if done carelessly. A single large DELETE can: When you’re cleaning up historical data or running routine maintenance, deleting rows in batches is usually the safest and most predictable approach. This post shows a simple, production-safe pattern…

  • Script: I/O Usage by Database

    This script returns total read and write activity per database based on file-level I/O statistics. It helps identify which databases are generating the most disk activity on the instance. This is commonly used during performance troubleshooting, storage pressure investigations, and workload analysis. The Script Example Output The result set shows one row per database, including…

  • Get Database Sizes and Free Space in SQL Server

    Keeping track of database file sizes and available free space is a basic but essential part of SQL Server administration. If you don’t know how large your data and log files are, or how much free space they contain, capacity planning becomes guesswork. Problems tend to surface late, usually during growth events, backups, or unexpected…

  • Show Database Growth Events in SQL Server

    Database file growth events are easy to ignore until they become a problem. When a data or log file autogrows, SQL Server pauses briefly to extend the file. If this happens frequently, it can introduce latency, increase I/O pressure, and in some cases trigger disk space incidents. For DBAs, understanding when files grow and which…

  • Script: Check Worker Threads and Active Sessions

    This script shows the current SQL Server worker thread count along with all active sessions and requests. It provides a live view of CPU usage, blocking, waits, running commands, and transaction activity. This is a practical script for performance troubleshooting when an instance appears busy, unresponsive, or under pressure. The Script Example Output The first…

  • RAND() vs NEWID() in SQL Server

    Most people searching for “random numbers in SQL Server” want one of two things: SQL Server gives you two common tools for this: RAND() and NEWID(). They solve different problems, and confusion usually starts when they are treated as interchangeable. This post shows how to use both, starting with simple examples, and explains why they…