[SQL Server] Afficher l'historique de restauration des bases
-- =============================================
-- Author: Zouhaier KHARROUBI
-- Create date: 16/06/2019
-- Description: Afficher l'historique de restauration des bases
-- =============================================
SELECT T1.[name],T2.restore_date
,restore_type = CASE T2.restore_type WHEN 'D' THEN 'FULL'
WHEN 'I' THEN 'DIFF'
WHEN 'L' THEN 'LOG'
ELSE NULL END
,T2.[replace],T2.[recovery]
,T3.backup_start_date,T3.backup_finish_date,T3.[type],T4.physical_device_name
FROM [msdb].sys.databases T1
LEFT JOIN [msdb].[dbo].restorehistory T2 ON T2.destination_database_name=T1.[name] AND CAST(T2.restore_date AS DATE)=CAST(GETDATE() AS DATE)
LEFT JOIN [msdb].[dbo].[backupset] T3 ON T3.backup_set_id=T2.backup_set_id
LEFT JOIN [msdb].[dbo].[backupmediafamily] T4 ON T4.media_set_id=T3.media_set_id
WHERE T1.[name] IN ('MaBase1','MaBase2','MaBase3')
ORDER BY T1.[name],T2.restore_date