SELECT ev.event_id AS externalId, ev.severity AS severity, ev.task_display_name AS taskDisplayName,
ev.product_name AS product_name, ev.product_version AS product_version,
ev.event_type As deviceEventClassId, ev.event_type_display_name As event_subcode, ev.descr As msg,
CASE
WHEN ev.rise_time is not NULL THEN DATEADD(hour,DATEDIFF(hour,GETUTCDATE(),GETDATE()),ev.rise_time )
ELSE ev.rise_time
END
AS endTime,
CASE
WHEN ev.registration_time is not NULL
THEN DATEADD(hour,DATEDIFF(hour,GETUTCDATE(),GETDATE()),ev.registration_time )
ELSE ev.registration_time
END
AS kscRegistrationTime,
cast(ev.par7 as varchar(4000)) as sourceUserName,
hs.wstrWinName as dHost,
hs.wstrWinDomain as strNtDom, serv.wstrWinName As kscName,
CAST(hs.nIp / 256 / 256 / 256 % 256 AS VARCHAR) + '.' +
CAST(hs.nIp / 256 / 256 % 256 AS VARCHAR) + '.' +
CAST(hs.nIp / 256 % 256 AS VARCHAR) + '.' +
CAST(hs.nIp % 256 AS VARCHAR) AS sourceAddress,
serv.wstrWinDomain as kscNtDomain,
CAST(serv.nIp / 256 / 256 / 256 % 256 AS VARCHAR) + '.' +
CAST(serv.nIp / 256 / 256 % 256 AS VARCHAR) + '.' +
CAST(serv.nIp / 256 % 256 AS VARCHAR) + '.' +
CAST(serv.nIp % 256 AS VARCHAR) AS kscIP,
CASE
WHEN virus.tmVirusFoundTime is not NULL
THEN DATEADD(hour,DATEDIFF(hour,GETUTCDATE(),GETDATE()),virus.tmVirusFoundTime )
ELSE ev.registration_time
END
AS virusTime,
virus.wstrObject As filePath,
virus.wstrVirusName as virusName,
virus.result_ev as result
FROM KAV.dbo.ev_event as ev
LEFT JOIN KAV.dbo.v_akpub_host as hs ON ev.nHostId = hs.nId
INNER JOIN KAV.dbo.v_akpub_host As serv ON serv.nId = 1
Left Join KAV.dbo.rpt_viract_index as Virus on ev.event_id = virus.nEventVirus
where registration_time >= DATEADD(minute, -191, GetDate())