Situatie
Mai jos este o procedura ce primeste ca parametru numele unei baze de date microsoft sql server si returneaza, pentru acea baza de date, istoricul retorurilor efectuate pe acel server de sql, data fiecarui restore, data backup-ului folosit in restore, numele cu care a fost restaurat baza de date precum si backup-ul folosit la restaurarea respectiva.
Solutie
— exec FindRestoreHistoryPrc ‘DatabaseName’
CREATE PROCEDURE FindRestoreHistoryPrc
@DatabaseName varchar(max)
as
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.[dbo].[restorehistory] rs
JOIN msdb.[dbo].[backupset] bs ON rs.[backup_set_id] = bs.[backup_set_id]
JOIN msdb.[dbo].[backupmediafamily] bmf ON bs.[media_set_id] = bmf.[media_set_id]
where bs.[database_name] = @DatabaseName
ORDER BY rs.[restore_date] DESC
Leave A Comment?