SQL Server: how to query when the last transaction log backup has been taken?

juur picture juur · Sep 25, 2010 · Viewed 37k times · Source

I would like to query for all databases (in SQL Server 2008 instance) date when the last transaction log backup has been taken. How to do that? I know that this information is somewhere, but I don't know where.

Answer

Martin Smith picture Martin Smith · Sep 25, 2010
SELECT   d.name,
         MAX(b.backup_finish_date) AS backup_finish_date
FROM     master.sys.sysdatabases d
         LEFT OUTER JOIN msdb..backupset b
         ON       b.database_name = d.name
         AND      b.type          = 'L'
GROUP BY d.name
ORDER BY backup_finish_date DESC