Database Experts:Last backup and Last Backup restore Information

For Finding latest backup details of all databases.

SELECT 
   
CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server,
   
msdb.dbo.backupset.database_name
   
MAX(msdb.dbo.backupset.backup_finish_dateAS 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' --'L' for transaction logsGROUP BY
   
msdb.dbo.backupset.database_name  ORDER BY 
   
msdb.dbo.backupset.database_name



For Finding latest restore backup for all databases.

SELECT MAX(restore_date) AS LastRestore,COUNT(*) AS CountRestores ,destination_database_name
FROM msdb.dbo.restorehistory
GROUP BY destination_database_name
order by 1 Desc
 

Comments

Popular posts from this blog

Agent Installation on Windows Server. SQL Server (Failover Cluster) target addition in OEM 12c

Oracle 10g/11g Linux:SMS the alert logs ORA- errors generated in timestamp

Oracle 11g: Install Instant Client 11.2.0.3.0 on Linux x86_64 Server.