Skip to content

Instantly share code, notes, and snippets.

@yngwie74
Created August 17, 2012 17:40

Revisions

  1. Alfredo Chavez created this gist Aug 17, 2012.
    26 changes: 26 additions & 0 deletions gistfile1.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    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