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 Rename a Computer that Hosts SQL Server

    When changing the hostname of a computer that is running SQL Server, we have to update system metadata so that remote connections and applications do not lose connectivity. The hostname system metadata is stored in sys.servers and reported by @@SERVERNAME. This post is a guide on how to update…

    Read More


  • Get Database Sizes in SQL Server

    Knowing how much disk space your databases are consuming in SQL Server is an important thing to know and monitor as a Database Administrator. As well as this, we should be looking at future growth of database files, ensuring we have enough disk space for years to come.…

    Read More


  • How to Backup a SQL Server Database

    This guide provides a simple demo on how to back up a SQL Server database and explains three main types of backups in MS SQL: > SQL Server Full Backup > SQL Server Transaction Log Backup > SQL Server Differential Backup > Additional Notes on SQL Server Backups…

    Read More


  • Get Estimated Database Backup/Restore Example

    When you’re waiting on a database backup or restore to complete in SQL Server, we can run the script below to get an estimated time of how long the backup has left to go – We have one 5GB database here currently being backed up at the time…

    Read More


  • Get Last Backup Times for all Databases in SQL Server

    Ensuring your databases are regularly backed up is critical for data recovery in case of corruption, accidental deletions, or other failures. If you don’t have a backup, recovering lost data may be impossible. As a Database Administrator, it’s your number one Priority along-side ensuring your SQL Service is…

    Read More


  • How to Check Table Sizes in SQL Server

    In this post, I’m sharing how to check table sizes in SQL Server. There’s many ways to get this information, and whether you prefer using T-SQL scripts for automation, or SSMS tools for quick checks, these methods offer flexibility for different situations as a SQL Database Administrator. If…

    Read More


  • Drop Table if Exists in SQL Server

    The DROP TABLE command in SQL Server will do as it suggests and drops a table. This post is to show an example of using this command, including the IF EXISTS argument. DROP TABLE IF EXISTS in MS SQL allows us to conditionally drop the table, meaning it…

    Read More


  • Get Last Database Restore Date and Time in SQL Server

    This guide provides a script to retrieve the last restore date and time for each database in SQL Server. It’s particularly helpful for tracking restore operations or verifying backups during disaster recovery scenarios. The script below queries the sys.databases and dbo.restorehistory system tables to get the most recent…

    Read More


  • List All SQL Agent Jobs on a SQL Server Instance

    This post contains a SQL script that will return a list of all SQL Server Agent Jobs on a Microsoft SQL Server instance. The sysjobs and sysjobsteps tables we are querying are in the M-S-D-B database. Interesting fact, I am unable to publish a post with this actual…

    Read 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