select sec.primary_server,sec.primary_database primario,
sec.secondary_server,sec.secondary_database secundario,
sec.last_copied_date data_copia_log,
sec.last_copied_file log_copiado,
sec.last_restored_date data_log_aplicado,
sec.last_restored_file log_aplicado,
sec.history_retention_period retencao,
DATEDIFF(minute, sec.last_copied_date, getdate()) tempo_desde_ultima_copia,
DATEDIFF(minute, sec.last_restored_date, getdate()) tempo_desde_ultimo_restore,
sec.last_restored_latency restore_latencia_minutos,
sec.restore_threshold latencia_alarme_minutos,
case when isnull(sec.last_restored_latency,0) <= isnull(sec.restore_threshold,0) then 'sincronizado' else 'sem sincronia' end status
from msdb.dbo.log_shipping_monitor_secondary sec
where convert(varchar,sec.last_copied_date,112) = convert(varchar,getdate(),112)
order by sec.primary_server,sec.primary_database
--and sec.primary_database ='Banco_teste'
SQL