SQL Server – Check Recent Backup of All Your SQL Server Databases

Do you have a recent backup of all your SQL Server databases? Use the script below to check ​​ if you have.

 

 

SELECT​​ B.name​​ as​​ Database_Name,​​ ISNULL(STR(ABS(DATEDIFF(day,​​ GetDate(),​​ 

MAX(Backup_finish_date)))),​​ 'NEVER')​​ as​​ DaysSinceLastBackup,

ISNULL(Convert(char(10),​​ MAX(backup_finish_date),​​ 101),​​ 'NEVER')​​ as​​ LastBackupDate

FROM​​ master.dbo.sysdatabases​​ B​​ LEFT​​ OUTER​​ JOIN​​ msdb.dbo.backupset A​​ 

ON​​ A.database_name​​ =​​ B.name​​ AND​​ A.type​​ =​​ 'D'​​ GROUP​​ BY​​ B.Name​​ ORDER​​ BY​​ B.name

 

 

Knowledge worth sharing...Share on linkedin
Linkedin
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter
Bookmark the permalink.

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *