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…

  • The SSMS Import Flat File Feature

    The Import Flat File feature within SQL Server Management Studio (SSMS) was introduced in December 2017 (14.0.17213.0). This is a streamlined version of the Import Data feature and it minimises the user intervention during a file import. Unlike the Import data feature, you don’t have the option to…

    Read More


  • Attaching SQL Databases Without Log Files

    In a perfect world, you’d never lose a database log file. But when the unexpected happens and you urgently need the data from a database, knowing how to attach a SQL Server database without its log (.ldf) file can be a lifesaver. This guide walks you through the…

    Read More


  • SQL Server Backup & Restore WITH FILE Option

    When you back up a SQL Server database, multiple backups can be stored in a single file. The WITH FILE = X option allows you to choose a specific backup version from a single backup file. Here’s what happens: – WITH FILE = 1: Restores the first backup…

    Read More


  • Applying Data Retention to a SQL Table

    In SQL Server, there’s often a need to delete old data from a database table. This could be for reasons like adhering to GDPR policies, managing oversized tables that are slowing down operations, staying within SQL Server Express’s 10GB limit, or simply cleaning up application logs and errors.…

    Read More


  • How to Change Connection Colours in SSMS

    SQL Server Management Studio (SSMS) is the go-to tool for running SQL Server queries. One of its handy features is the ability to change the colour of the query banner, providing a visual indicator of the server environment you are connected to. This feature can be especially beneficial…

    Read More


  • Exporting SQL Server Query Results to CSV

    This guide explains how to export a SQL Server query results to a CSV file using SSMS. SQL Server Management Studio (SSMS) is the primary tool used for managing SQL Server databases and running queries. By default, SSMS exports data in a column-aligned format, but to export data…

    Read More


  • How to Quickly Get Table Sizes in SQL Server

    Monitoring table sizes in SQL Server is crucial for effective database management. For a detailed guide covering various methods, including built-in reports and custom scripts, please refer to my latest article on this: How to Check Table Sizes in SQL Server. In this guide, we’ll show a few…

    Read More


  • How to Backup a SQL Server Database

    Ensuring regular backups of your SQL Server database is essential for data protection and disaster recovery. Whether you prefer using SQL commands or SQL Server Management Studio (SSMS), this guide will walk you through both methods. Backing Up a SQL Server Database Using T-SQL If you want a…

    Read More


  • Restoring Full Database Backup in SQL Server

    Restoring a full backup file in SQL Server is a fundamental task for database administrators and developers. This guide walks you through the process step by step, highlighting some key options to use. Full backups capture the entire database, including all data and the transaction log necessary for…

    Read More


  • How to Properly Copy SQL Dates into Excel

    When copying a SQL query result directly into Excel, DATETIME columns often don’t display as expected. Excel doesn’t seem to handle milliseconds well, making the dates appear messy. The Issue: Excel Precision Struggles Here’s an example of data I copied over from SQL Server into an Excel sheet.…

    Read More