We had to re-build our Solarwinds Environment and noticed that when we imported some of our custom alerts all of the SQL items had an error.
Is anyone having any issues with SQL pulled items in there alert Email, here is an example of one of our SQL quays that is getting the error now.
${SQL: Select
'Triggered in the last 7 days: '+ cast(Last_7 as varchar(max))+CHAR(13)+CHAR(10) +'Triggered in the last 30 days: '+ cast(Last_30 as varchar(max)) +CHAR(13)+CHAR(10)+ 'Triggered in the previous 30 days: ' + cast(Prev_30 as varchar(max))
from
(SELECT Count(1)as Last_7 FROM [dbo].[AlertHistoryView] where EventTypeWord='Triggered' and alertid=${N=Alerting;M=AlertID} and RelatedNodeId=${N=SwisEntity;M=NodeID} and TimeStamp > DATEADD(DAY, -7, GETDATE()) ) Last7 ,
(SELECT Count(1)as Last_30 FROM [dbo].[AlertHistoryView] where EventTypeWord='Triggered' and alertid=${N=Alerting;M=AlertID} and RelatedNodeId=${N=SwisEntity;M=NodeID} and TimeStamp > DATEADD(DAY, -30, GETDATE())) Last30,
(SELECT Count(1)as Prev_30 FROM [dbo].[AlertHistoryView] where EventTypeWord='Triggered' and alertid=${N=Alerting;M=AlertID} and RelatedNodeId=${N=SwisEntity;M=NodeID} and TimeStamp between DATEADD(DAY, -60, GETDATE()) and DATEADD(DAY, -30, GETDATE())) Prev30}
This should display alerts triggered on a device for the last 7 days, 30 days and 60 days
Example:
Historical alert statistics
Triggered in the last 7 days: 2
Triggered in the last 30 days: 4
Triggered in the previous 30 days: 0
but since we rebuilt the environment we are getting the following:
MACRO SQL ERROR - No column name was specified for column 1 of '3d2sbrwf_erb'.