Agent Jobs

Get How Old SQL Database Backups Are

Here’s some quick SQL Logic that will show you the age of your backups.

use master;
set nocount on

'database' = upper(bs.database_name)
,	'backup date' = datename(dw, bs.backup_finish_date) + ' ' + convert(char, bs.backup_finish_date, 9) ,	'type' =
case bs.type
when 'L' then 'TLOG'
when 'D' then 'FULL'
,	'num days old' = left((datediff(s, bs.backup_finish_date, getdate())/86400.0),6) ,	'location' = bmf.physical_device_name
msdb..backupset bs join msdb..backupmediafamily bmf on bs.media_set_id = bmf.media_set_id
--	bs.database_name = 'mydatabase'
--	and bs.type = 'D'
order by
bs.backup_finish_date desc

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s