Category: SQL Server

SQL Server Blog Archives, by Peter Whyte (Database Administrator).
Includes: Database Admin, Management Studio (SSMS), Windows Admin, PowerShell, WSL, MSSQL Backups, Restores & more…

  • How to Restore a Database in SQL Server

    Restoring a database in SQL Server is an essential task for any Database Administrator. Whether it’s part of a disaster recovery plan, setting up a test environment, or moving data between servers, you’ll likely restore databases countless times in your career. You can restore databases through the SQL…

    Read More


  • What’s New in the SQL Server 2022 Install

    SQL Server 2022 was officially unveiled at Microsoft Build 2022, an annual event aimed at software developers passionate about Microsoft technologies. The conference, which focuses on Microsoft Azure updates and other key tools, is a fantastic opportunity for professionals to stay informed, learn, and network. It includes a…

    Read More


  • Why Use WHERE 1=2 in SQL

    In a previous blog post, I explained why WHERE 1=1 is often used in SQL queries. This time, let’s discuss WHERE 1=2 — or any condition that results in a FALSE value, such as WHERE 1=9. Essentially, the point is to use a condition that is guaranteed to…

    Read More


  • Get All Database Sizes & Free Space Info In SQL Server

    Monitoring database file sizes and free space within data and log files is an important part of monitoring SQL Server health. This information, along with other metrics such as growth events, can help you to better predict and plan for future disk space provisioning needs. The following script…

    Read More


  • Searching for a String Across All Tables in SQL Server

    When working with SQL Server, you might need to find where a specific string exists in a database. This is especially useful when working with large or unfamiliar schemas. For example, you may want to check where a value like a username, email, or other data is stored…

    Read More


  • Show Only the Domain of an Email Address in SQL Server

    When performing data analysis of email data in SQL, there’s often a need to show only the domain of an email address. You can use this for things like checking invalid emails or to find out your most populous domains. In this blog post, I’ll show how to…

    Read More


  • The USE Database Statement in SQL Server

    The USE [database] command in SQL Server is used to switch the context to a specific database when running queries. This is useful when you need to work with multiple databases or change the active database during a session. When to use this statement:– When you want to…

    Read More


  • Disk Usage by Top Tables Report in SQL Server

    The Disk Usage by Top Tables Report in SQL Server is a quick way to get the sizes of all tables within a database. It’ll show all tables largest to smallest tables by total size on disk. If you notice that a database is growing larger in size,…

    Read More


  • SQL Script: Get Last Backup Times in SQL Server

    Backing up databases is crucial for data protection in SQL Server, yet it’s surprising how often business-critical databases lack proper backups. When reviewing a new SQL Server instance, one of the first tasks is checking the last backup times to ensure recovery points are available before making any…

    Read More


  • Why use WHERE 1=1 in SQL Queries

    A common SQL question is, why would anyone use WHERE 1=1 in their queries? And what does it do? The WHERE 1=1 condition means WHERE TRUE. It returns the same query result as it would without the WHERE Clause. There is no impact on query execution time. This…

    Read More