Labels

Thursday, 2 March 2017

Script to find when backup started and finished in SQL Server

In order to get the backup start date and backup end date we need to use backupfile,backupmediafamily and backupset tables with dbo schema available in msdb system database .


SELECT CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS SERVER
 ,msdb.dbo.backupset.database_name
 ,msdb.dbo.backupset.backup_start_date
 ,msdb.dbo.backupset.backup_finish_date
 ,msdb.dbo.backupset.expiration_date
 ,CASE msdb..backupset.type
  WHEN 'D'
   THEN 'Database'
  WHEN 'L'
   THEN 'Log'
  END AS backup_type
 ,msdb.dbo.backupset.backup_size
 ,msdb.dbo.backupmediafamily.logical_device_name
 ,msdb.dbo.backupmediafamily.physical_device_name
 ,msdb.dbo.backupset.NAME AS backupset_name
 ,msdb.dbo.backupset.description
FROM msdb.dbo.backupmediafamily
INNER JOIN msdb.dbo.backupset ON
ORDER BY msdb.dbo.backupset.database_name ,msdb.dbo.backupset.backup_finish_date

No comments:

Post a Comment