HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Query agent jobs for a given notification operator name

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
operatorqueryagentjobsnameforgivennotification

Problem

Is there a good way to query sql agent jobs for success / failure notification to a given operator name?
One of the operators is no longer with the company and need to fix up all agent jobs sending failure notifications to that person.

Solution

Please try following T-SQL query:

USE [msdb]
GO

   SELECT j.[name] AS [JobName]
    FROM [dbo].[sysjobs] j
    LEFT JOIN [dbo].[sysoperators] o ON (j.[notify_email_operator_id] =o.[id] )
    WHERE o.[id]=1 ----or o.[name]='your operator name'
     and j.[enabled] = 1 
        AND j.[notify_level_email] IN (1,2)


This should be able to query the jobs for success or failure notification to a specified operator.

Code Snippets

USE [msdb]
GO

   SELECT j.[name] AS [JobName]
    FROM [dbo].[sysjobs] j
    LEFT JOIN [dbo].[sysoperators] o ON (j.[notify_email_operator_id] =o.[id] )
    WHERE o.[id]=1 ----or o.[name]='your operator name'
     and j.[enabled] = 1 
        AND j.[notify_level_email] IN (1,2)

Context

StackExchange Database Administrators Q#281158, answer score: 3

Revisions (0)

No revisions yet.