Created
August 17, 2012 17:40
-
-
Save yngwie74/3380899 to your computer and use it in GitHub Desktop.
Determinar cuando se hizo un "RESTORE" a un BD por última vez en SQL Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT rsh.destination_database_name AS [Database] | |
,rsh.user_name AS [Restaurado por] | |
,CASE | |
WHEN rsh.restore_type = 'D' THEN 'Database' | |
WHEN rsh.restore_type = 'F' THEN 'File' | |
WHEN rsh.restore_type = 'G' THEN 'Filegroup' | |
WHEN rsh.restore_type = 'I' THEN 'Differential' | |
WHEN rsh.restore_type = 'L' THEN 'Log' | |
WHEN rsh.restore_type = 'V' THEN 'Verifyonly' | |
WHEN rsh.restore_type = 'R' THEN 'Revert' | |
ELSE rsh.restore_type | |
END AS [Tipo] | |
,rsh.restore_date AS [Fecha] | |
,bmf.physical_device_name AS [Origen] | |
,rf.destination_phys_name AS [Destino] | |
FROM msdb.dbo.restorehistory rsh | |
INNER JOIN msdb.dbo.backupset bs | |
ON rsh.backup_set_id = bs.backup_set_id | |
INNER JOIN msdb.dbo.restorefile rf | |
ON rsh.restore_history_id = rf.restore_history_id | |
INNER JOIN msdb.dbo.backupmediafamily bmf | |
ON bmf.media_set_id = bs.media_set_id | |
WHERE rsh.restore_date >= DATEADD(month, -6, GETDATE()) | |
-- agregar si solo se quiere una base, quitar para todas | |
-- AND destination_database_name = 'OKW' | |
ORDER BY rsh.destination_database_name DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment