Find the backup file name which is used to restore the a database in SQL Server

To check which Backup file was used to restore a Database use this command: 

SELECT 
  [rs].[destination_database_name], 
  [rs].[restore_date], 
  [bs].[backup_start_date], 
  [bs].[backup_finish_date], 
  [bs].[database_name] as [source_database_name], 
  [bmf].[physical_device_name] as [backup_file_used_for_restore] 
FROM 
  msdb..restorehistory rs 
  INNER JOIN msdb..backupset bs ON [rs].[backup_set_id] = [bs].[backup_set_id] 
  INNER JOIN msdb..backupmediafamily bmf ON [bs].[media_set_id] = [bmf].[media_set_id] 
where 
  [rs].[destination_database_name] like 'DBNAME' 
ORDER BY 
  [rs].[restore_date] DESC;

Comments

Popular posts from this blog

How to Enable / Disable a user in MS SQL Server

How to Create a Database in MS SQL Server