February 27, 2015 at 11:50 am
I'm using the following to add job notifications but I need a script to undo it in before I can submit to dba team:
EXEC msdb.dbo.sp_update_job
@job_name=N'MyJobName',
@notify_level_email=3,
@notify_email_operator_name=N'Team'
GO
Is there a script that can un do the script above? I tried using
EXEC msdb.dbo.sp_update_job
@job_name=N'MyJobName',
@notify_level_email=0,
@notify_email_operator_name=N'Team'
GO
But I get an error saying "Msg 14266, Level 16, State 1, Procedure sp_verify_job, Line 249
The specified '@notify_level_email' is invalid (valid values are: 1, 2, 3)."
February 27, 2015 at 1:56 pm
Use the following to remove the notification.
EXEC msdb.dbo.sp_update_job
@job_name=N'MyJobName',
@notify_email_operator_name=N''
GO
March 1, 2015 at 9:12 am
I think if you simply change the email_level to 0 then you will only be undoing part of what your initial script is doing. The sp_update_job stored proc only changes the values of parameters that are supplied, leaving the others unchanged. I am guessing your original code maybe does not work because you would not typically want an email operator assigned if the email_level indicates that an email should not be sent. Try the below to remove email notification and the operator.
EXEC msdb.dbo.sp_update_job
@job_name=N'MyJobName',
@notify_level_email=0,
@notify_email_operator_name=N''
GO
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply