编辑:我让它带回我需要的信息,但是 where 子句没有过滤掉所有类型为“L”的备份,如果我从 (bak.type = 'D' ...) 周围取括号,那么然后它不会过滤掉所有的系统数据库。任何想法?
这就是我所拥有的。我试图加入 msdb..backupset 和 msdb.dbo.backupmediafamily 以获得类型为 D 和 device_type 为 2。任何帮助都会被应用。谢谢!
SELECT DISTINCT
CONVERT(varchar,GETDATE()-1,111) AS Missing_Backup_Date,
@@servername AS Instance_Name,
bak.database_name AS Database_Name,
DATENAME(weekday, getdate()-1) AS Backup_Day_of_Week,
bak.type AS Failure_Count,
fam.device_type,
CASE fam.device_type
when 2 then 'SQL'
when 7 then 'Avamar'
END AS Backup_Type
FROM msdb..backupset bak
JOIN msdb.dbo.backupmediafamily fam
ON bak.media_set_id = fam.media_set_id
WHERE bak.database_name NOT IN ('tempdb','msdb','master','model')
AND (bak.type = 'D'
AND bak.backup_finish_date IS NULL OR bak.backup_finish_date < DATEADD(hour, -24, GETDATE()))