Wednesday, April 18, 2018

When was the last transaction log backup taken?

Good question.  I was reviewing a customer's backup status today, and I needed to answer that question -- when was the last tranlog backup run?  It is a fast statement, and I have included the recovery model in with each database, so that you can see which ones are FULL recovery, and where the backups may be missing.

     SELECT
          d.name [Database],
          d.recovery_model_desc [RecoveryModel],
          MAX(b.backup_finish_date) [BackupDate]
     FROM
          master.sys.databases d LEFT OUTER JOIN msdb..backupset b
             ON b.database_name = d.name
             AND b.type = 'L'
     GROUP BY 
          d.name
          d.recovery_model_desc
     ORDER BY 
          d.name;

Your resultset will be a little something like this:
















If the database recovery models are correct, then you may need to get some backups into place on that Orders database.  

See this for more details on SQL Server's transaction log backups:

No comments:

Post a Comment