Audit date of last SQL backup

Deepak over at SQLKnowledge wrote a very simple SQL query that will let you know when the last date of a backup was completed for all databases within a server.

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

Advertisements

About noneil
Rapper turned Rockstar!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: