Author: Peter Whyte

  • Checking Table Sizes in SQL Server

    Checking table sizes in SQL Server is a routine DBA task that supports capacity planning, performance troubleshooting, and data retention work. There are several ways to get this information. Some methods are better suited to automation and reporting, while others are quicker for ad hoc checks in SQL Server Management Studio. This post walks through…

  • Script: Get Instance Configuration Snapshot

    This script returns a focused snapshot of instance-level configuration settings that DBAs commonly review when validating a server, inheriting an environment, or troubleshooting unexpected behaviour. It intentionally surfaces settings that have operational, security, or performance impact when misconfigured or left unchecked. The Script Example Output The result set shows the current values for key instance…

  • Understanding WHERE 1=1 and WHERE 1=2 in SQL Queries

    In SQL, you will often see queries written using WHERE 1=1 or WHERE 1=2. At first glance, both look pointless. One is always true, the other always false. In practice, both are deliberate patterns used for query construction and control, not filtering logic. They exist to make SQL safer, easier to manipulate, and more predictable…

  • Script: Check MAXDOP Configuration

    This script shows the current MAXDOP setting and helps you quickly validate whether it’s likely to be sensible for the server you’re connected to. It includes the configured MAXDOP value and core visibility information so you can make an informed call without digging through multiple places. The Script Example Output The first result set shows…

  • Script: Get Memory Configuration and Usage

    This script shows how memory is configured for SQL Server and how much memory is currently being used. It helps confirm that instance-level memory settings are sensible and whether SQL Server or the host appears to be under memory pressure. This is commonly checked during performance investigations, post-build validation, and when reviewing servers that are…

  • How to Open PowerShell as Administrator on Windows

    Running PowerShell as Administrator is required for many system-level tasks such as configuring Windows, installing software, or running administrative scripts. If a command fails unexpectedly, one of the first things to verify is whether the PowerShell session is actually elevated. Below are the most reliable ways to open PowerShell with elevated privileges on Windows. Quick…

  • Script: Get CPU Topology and Core Counts

    This script returns how CPU resources are presented to SQL Server, including NUMA nodes, CPU counts, and scheduler distribution. It helps confirm whether the instance is seeing the hardware as expected and whether CPU layout aligns with licensing, performance, and workload design. This is typically checked during performance investigations, new server validation, and post-migration reviews.…

  • Disk Usage by Top Tables Report in SQL Server

    The Disk Usage by Top Tables report in SQL Server Management Studio is one of the quickest ways to see where space is being used inside a database. It shows table sizes sorted largest to smallest, along with row counts and index space, making it ideal for fast investigation when a database starts growing unexpectedly.…

  • Script: Check SQL Server Version and Edition

    This script returns the exact SQL Server version, build, edition, and servicing level for the current instance. It’s intended as a fast, reliable way to confirm what is actually running, without relying on UI dialogs or partial version strings. This is typically one of the first checks during troubleshooting, audits, upgrades, or when validating environments.…

  • What the USE Command Does in SQL Server

    The USE command changes the database context for the current session. Every statement in SQL Server runs in the context of a database. When you run USE, you are telling SQL Server which database subsequent statements should execute against until the context changes again or the session ends. That single behaviour explains a lot of…