Network Management
Add SQL queries to alert email notification
This article provides information on adding SQL queries to the alert email notification.
First published date
Last published date
Overview
This article provides information on adding SQL queries to the alert email notification.
Product section
Cause
Resolution
Orion Alerting Engine provides one macro which allows to execute SQL query and returns results. Basic syntax is as folows:
${SQL: SQL-QUERY}
where SQL-QUERY can be replaced by any (possibly) SQL statement. For example:
SELECT REPLACE('abcdefghicde','cde','xxx')
SELECT @@VERSION
SELECT SERVERPROPERTY('productversion')
SELECT SERVERPROPERTY('productlevel')
SELECT SERVERPROPERTY('edition')
The equivalent to be used in the alert email body:
${SQL: SELECT REPLACE('abcdefghicde','cde','xxx')}
${SQL: SELECT @@VERSION}
${SQL: SELECT SERVERPROPERTY('productversion')}
${SQL: SELECT SERVERPROPERTY('productlevel')}
${SQL: SELECT SERVERPROPERTY('edition')}
and the final result in the email alert:
abxxxfghixxx Microsoft SQL Server 2014 - 12.0.4213.0 (X64) Jun 9 2015 12:06:16 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor) 12.0.4213.0 SP1 Enterprise Edition (64-bit)
Notes:
- If the SQL-QUERY returns multiple records, only the first one (top-most) will be displayed as a result.
- If the SQL-QUERY returns multiple columns, only the first one (left-most) will be displayed as a result.
- If the SQL-QUERY returns multiple records and multiple columns, only the top-left-most will be displayed as a result.