Advertisements

SQL-BOX.COM

–SQL Server Storage

Script to find Backup History- SQL Server

This Script gives the backup history of all databases with in a instance. Also gives you when is the database last backed up ?

SELECT 
CONVERT(CHAR(100),
SERVERPROPERTY('Servername')) AS Server,
msdb.dbo.backupset.database_name, 
MAX(msdb.dbo.backupset.backup_finish_date) AS last_db_backup_date
FROM  
msdb.dbo.backupmediafamily  INNER JOIN msdb.dbo.backupset
ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id 
WHERE  msdb..backupset.type = 'D'
GROUP BY msdb.dbo.backupset.database_name 
ORDER BY msdb.dbo.backupset.database_name

If this script is useful to you leave a comment saying what type of query else you would like to see in here.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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: