Submit a ticketCall us

AnnouncementsChange Is Inevitable

Get valuable help when it comes to tracking and monitoring changes. SolarWinds® Server Configuration Monitor (SCM) is designed to help you: detect, track, and receive alerts when changes occur, correlate system performance against configuration changes, compare server and application configuration against custom baselines, and verify application and system changes.

Learn more.

Home > Success Center > Network Performance Monitor (NPM) > NPM - Knowledgebase Articles > Add SQL queries to alert email notification

Add SQL queries to alert email notification

Created by Mariusz Handke, last modified by MindTouch on Jun 23, 2016

Views: 3,642 Votes: 1 Revisions: 4

Overview

This article provides information on adding SQL queries to the alert email notification.

Environment

All Orion Platform

Details

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.

 

 

 

Last modified

Tags

Classifications

Public