Author: Peter Whyte

  • 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


  • Counting Rows within CSV Files using PowerShell

    This post contains a script that will help count rows within multiple CSV files using PowerShell. If you have a directory containing many CSV files, this’ll help you count the rows of each CSV file within the folder. Counting rows within CSV files may be useful for verifying…

    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 Check Table Sizes in SQL Server

    There are many ways to check the size of a table in SQL Server. The way you will do it will likely depend on what your task at-hand is. For example, a quick look at the Disk Usage by Top Tables report on a database you’ve never seen…

    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


  • Stack Exchange Data Explorer

    As a DBA, I’ve found Stack Exchange Data Explorer to be a really useful tool for exploring and analyzing the data from the Stack Exchange network of websites. It’s kind of like having a SQL playground where you can run all sorts of queries and see what insights…

    Read More


  • Monitoring Database Growth Events in SQL Server

    Database growth events occur when a SQL Server database file reaches its capacity and automatically grows to accommodate more data. These events are configured in the database properties, where you can define growth increments in MB or GB. Properly configuring these settings is important for maintaining performance, as…

    Read More