Este script nos ayuda a sacar reportes de cuando fue restaurada una base de datos o cuando fue realizado su último backup.
Reporte de restauraciones de una base de datos
DECLARE @fecha datetime, @bd varchar(25)
set @fecha = '01/15/2005'
set @bd = 'Northwind'select h.destination_database_name,h.restore_date,f.destination_phys_name, h.user_name,CASE h.restore_type
WHEN 'D' THEN 'Database'
WHEN 'F' THEN 'File'
WHEN 'G' THEN 'Filegroup'
WHEN 'L' THEN 'Log'
WHEN 'L' THEN 'Verifyonly'
END as Type
from
msdb..restorefile f, msdb..restorehistory h
where f.restore_history_id = h.restore_history_id
and restore_date >= @fecha
and destination_database_name = @bd
Reporte de Respaldos de una base de datos
DECLARE @fecha datetime, @bd varchar(25)
set @fecha = '01/15/2005'
set @bd = 'Nortwind'select b.server_name,b.database_name, physical_device_name,
CASE b.type
WHEN 'D' THEN 'Full Backup'
WHEN 'I' THEN 'Differential Backup'
WHEN 'L' THEN 'Log'
WHEN 'F' THEN 'File or Filegroup'
END as Type
,b.backup_size as "Size (bytes)",b.backup_start_date,
backup_finish_date,datediff(s,b.backup_start_date,b.backup_finish_date) as "Duration(sec)"
from msdb..backupset b, msdb..backupmediafamily m
where b.media_set_id=m.media_set_idand b.backup_start_date >= @fecha
and b.database_name = @bd order by b.backup_start_date