How to Find The Last Time the Database was Backed Up in SQL Server

Hello to everyone,

In this article, I will provide information about the last time the database was backed up in SQL Server.

In SQL Server, in some cases, you may want to know when the database was last backed up.

You can easily do this using the code below.,

SELECT db.name AS 'Database',
       db.database_id,
       CASE
           WHEN (b.type) = 'D' THEN
               'Full'
           WHEN (b.type) = 'I' THEN
               'Differential'
           WHEN (b.type) = 'L' THEN
               'Log'
           ELSE
               'Other'
       END AS 'Type',
       b.backup_start_date,
       b.backup_finish_date,
       b.user_name
FROM sys.databases db
    LEFT OUTER JOIN msdb.dbo.backupset b
        ON db.name = b.database_name
           AND b.type = 'D'
--WHERE db.database_id NOT IN (2) 
GROUP BY db.name,
         db.database_id,
         b.user_name,
         b.backup_start_date,
         b.backup_finish_date,
         b.type
ORDER BY backup_finish_date DESC;

When you run the above code, you will see a result similar to the one below.

How to Find The Last Time the Database was Backed Up in SQL Server

As you can see, the last backup dates of the database are seen.

Good luck to everyone in business and life.

325 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!