Tag: Database Admin

  • How to Backup a SQL Server Database

    This post contains a demo on how to backup a SQL Server Database and includes some information on the types of backups available in MS SQL. The 3 types of backups that will be covered in this post are:# MS SQL Full Backup# MS SQL Transaction Log Backup# MS SQL Differential Backup Before backing up…

    read more


  • Get Estimated Backup Restore Time in SQL Server

    This post contains a SQL script to get estimated completion times and process information for your currently running database backups & restores in SQL Server. Backing up a database can often take a very long time. It depends on various factors why a backup can take longer to complete. One more obvious reason is, that…

    read more


  • How to Get Last Backup Times for all Databases in SQL Server

    This is a post on how to get the last backup dates and times for all databases on a SQL Server Instance. Database backups are as important as the availability of your server. If your database gets corrupted, or there’s an accidental data deletion and you need to recover data, then we must rely on…

    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 does not cause an error if the…

    read more


  • Get Last Database Restore DateTimes in SQL Server

    This post contains a script to help you get the last dates and times for when your databases were last restored in SQL Server. The script below queries the M.S.D.B database sys.databases and restorehistory tables. You should get into the habit of searching MS Docs for every system table you query in SQL Server. This…

    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 database name without seeing a JSON error.…

    read more


  • How to Restore a Database in SQL Server

    Restoring a database in SQL Server is a straightforward task, and one that SQL Database Administrators have to perform thousands of times throughout their career. A database restore can be done via GUI (SSMS Wizard) or via command (TSQL/PowerShell). The method you choose to restore a database is usually driven by the number of databases…

    read more


  • Why Use WHERE 1=2 in SQL

    Some time ago I wrote a blog post on why use WHERE 1=1 in SQL. This time it’s why use WHERE 1=2, but really this can be WHERE 1=9 or anything that isn’t a 1, we just want the false statement. WHERE 1=1 is TRUE; has no difference on execution times and can be used…

    read more


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

    Tracking database file sizes and free space within data and log files is an important part of monitoring SQL Server. 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 provides a quick way to view database file…

    read more


  • Change Default Database in SQL Server

    When you log into SQL Server using SQL Server Management Studio (SSMS), opening a new query window will automatically scope you within the default database set when your user was created. If this isn’t explicitly set during creation it’ll be set to the master database which isn’t very convenient for users. DBA’s might have to…

    read more