To get the list of all backup operations performed on the current database instance:
SQL Code:
SELECT sdb.Name AS DatabaseName, COALESCE(CONVERT(VARCHAR(50), bus.backup_finish_date, 120),'-') AS LastBackUpDateTime FROM sys.sysdatabases sdb LEFT OUTER JOIN msdb.dbo.backupset bus ON bus.database_name = sdb.name ORDER BY sdb.name, bus.backup_finish_date DESC
Output:
To get the list of all restore operations performed on the current database instance:
SQL Code:
SELECT [d].[name] AS database_name, [r].restore_date AS last_restore_date, [r].[user_name], [bs].[backup_finish_date] AS backup_creation_date, [bmf].[physical_device_name] AS [backup_file_used_for_restore] FROM master.sys.databases [d] LEFT OUTER JOIN msdb.dbo.[restorehistory] r ON r.[destination_database_name] = d.Name INNER JOIN msdb.dbo.backupset [bs] ON [r].[backup_set_id] = [bs].[backup_set_id] INNER JOIN msdb.dbo.backupmediafamily bmf ON [bs].[media_set_id] = [bmf].[media_set_id] ORDER BY [d].[name], [r].restore_date DESC
Output:
Related Article:
- Retrieve information on backup and restore operations in SQL Server
- Return list of SQL Agent jobs with schedule information in SQL Server
- Count the Number of Tables in a Database in SQL Server
- Retrieve List of all Stored Procedures in SQL Server
- Display all data files for all databases with size and growth info in SQL Server
- Get all schemas, tables, columns and indexes in SQL Server
- Retrieve all Table detail from Known Column in SQL Server
- Get the list of all databases on a server in SQL Server
- Show Size of All Tables in Current Database in SQL Server
No comments:
Post a Comment