Hi All,
I'm trying to get an event tag to email a report out at a set time but all I can get it to do is email a blank report as soon as I include the query nothing happens
this is the Generic SQL I'm using :
Set Quoted_Identifier OFF
exec master..xp_sendmail
@recipients = "******.******@******.com",
@subject = "Data for @EventTagName at @EventTime",
@query = "SET NOCOUNT ON
DECLARE @StartDate DateTime
DECLARE @EndDate DateTime
SET @StartDate = DateAdd(hh,-24,GetDate())
SET @EndDate = GetDate()
SET NOCOUNT OFF
SELECT Description, DateTime, Value
FROM Tag, v_AnalogHistory
WHERE v_AnalogHistory.TagName IN ('AreaACanlineCaseCountLastHour')
AND Tag.TagName = v_AnalogHistory.TagName
AND wwVersion = 'Latest'
AND wwRetrievalMode = 'Cyclic'
AND wwRowCount = 24
AND DateTime >= @StartDate
AND DateTime
UNION
SELECT Description, DateTime, Value
FROM Tag, ManualAnalogHistory
WHERE ManualAnalogHistory.TagName IN ('AreaACanlineCaseCountLastHour')
AND Tag.TagName = ManualAnalogHistory.TagName
AND DateTime >= @StartDate
AND DateTime
ORDER BY DateTime DESC",
@no_output = "true"
The Query on its own works but it's not working as part of the email.Any ideas welcome
I'm trying to get an event tag to email a report out at a set time but all I can get it to do is email a blank report as soon as I include the query nothing happens
this is the Generic SQL I'm using :
Set Quoted_Identifier OFF
exec master..xp_sendmail
@recipients = "******.******@******.com",
@subject = "Data for @EventTagName at @EventTime",
@query = "SET NOCOUNT ON
DECLARE @StartDate DateTime
DECLARE @EndDate DateTime
SET @StartDate = DateAdd(hh,-24,GetDate())
SET @EndDate = GetDate()
SET NOCOUNT OFF
SELECT Description, DateTime, Value
FROM Tag, v_AnalogHistory
WHERE v_AnalogHistory.TagName IN ('AreaACanlineCaseCountLastHour')
AND Tag.TagName = v_AnalogHistory.TagName
AND wwVersion = 'Latest'
AND wwRetrievalMode = 'Cyclic'
AND wwRowCount = 24
AND DateTime >= @StartDate
AND DateTime
UNION
SELECT Description, DateTime, Value
FROM Tag, ManualAnalogHistory
WHERE ManualAnalogHistory.TagName IN ('AreaACanlineCaseCountLastHour')
AND Tag.TagName = ManualAnalogHistory.TagName
AND DateTime >= @StartDate
AND DateTime
ORDER BY DateTime DESC",
@no_output = "true"
The Query on its own works but it's not working as part of the email.Any ideas welcome
Last edited: