Skip to content

Instantly share code, notes, and snippets.

@jpomfret
Created April 28, 2024 16:22
Show Gist options
  • Save jpomfret/05b88a3ee350eda463b84963faffa752 to your computer and use it in GitHub Desktop.
Save jpomfret/05b88a3ee350eda463b84963faffa752 to your computer and use it in GitHub Desktop.
--restore history
SELECT rh.restore_date,bs.backup_start_date, rh.stop_at, rh.destination_database_name,
case rh.restore_type
when 'D' then 'Full'
when 'I' then 'Differential'
when 'L' then 'Log' end as Restore_Type, bs.server_name as SourceServer, bs.database_name as SourceDB, backup_size as backupsize_bytes, (backup_size * 0.000001) as backupsize_MB
FROM MSDB.DBO.restorehistory rh
inner join msdb.dbo.backupset bs
on rh.backup_set_id = bs.backup_set_id
ORDER BY rh.restore_date DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment