How to find last backup times of all databases on a SQL Server?

Please use below code to find last backup times of all databases hosted on a SQL Server instance:


-- Code to print last backup time of all database on a server
SELECT db.Name AS DatabaseName,
MAX(bus.backup_finish_date) AS LastBackUpTime
FROM sys.sysdatabases db
LEFT OUTER JOIN msdb.dbo.backupset bus ON bus.database_name = db.name
GROUP BY db.Name
order by LastBackUpTime asc

Note: This code is tested on SQL 2005/2008/2008R2 and 2012

Comments