Edit: I have it bringing back the info I need, but the where clause is not filtering out all the backups of type 'L' and if I take the parentheses from around the (bak.type = 'D' ...) then then it doesnt filter out all the sysdatabases. Any Idea?
Here is what I have. I was trying to Join msdb..backupset and msdb.dbo.backupmediafamily to get the type as D and the device_type as 2. Any help would be appricated. thanks!
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()))