We have a custom SQL report listing all servers with uptime > 60 days. We use this report to locate Windows hosts that have not been rebooted after their monthly patching run. The report can take 1-2 minutes to display in a browser, and this is causing issues with scheduling. The scheduled job sends an HTML email, which only displays the SAM login screen. The exact same scheduled task running a fast report returns the HTML data as expected. Does the below SQL query look optimal, or does it need to be restructured? If the structure is sound, are there ways to extend timeout settings on the scheduled task so that the data comes through? Thanks, C
select
x.Application_Name,
x.NodeID,
x.NodeName,
x.LastCheck,
convert(varchar,convert(int,APM_ResponseTime.StatisticData)/86400) + ' days ' + convert(varchar,(convert(int,APM_ResponseTime.StatisticData) % 86400 / 3600)) + ' hours ' + convert(varchar(2), ((convert(int,APM_ResponseTime.StatisticData) % 86400) % 3600) / 60) + ' minutes' AS Uptime
from
(select
Nodes.Application_Name AS Application_Name,
Nodes.NodeID AS NodeID,
Nodes.Caption AS NodeName,
RT.ComponentID as ComponentID,
max(RT.[DateTime]) AS LastCheck
from Nodes
inner join APM_AlertsAndReportsData ARD ON (Nodes.NodeID = ARD.NodeId)
inner join APM_ResponseTime RT ON (ARD.ComponentId = RT.ComponentID)
where ARD.ComponentName = 'System: Uptime'
group by Nodes.Application_Name,Nodes.NodeID,Nodes.Caption, RT.ComponentID) x
inner join APM_ResponseTime on APM_ResponseTime.[DateTime] = x.LastCheck and APM_ResponseTime.ComponentId = x.ComponentID
WHERE APM_ResponseTime.StatisticData > 5184000
order by 1 asc, 3 asc