--Check to see if operator exists currently:
SELECT [name], [id], [enabled] FROM msdb.dbo.sysoperators
ORDER BY [name];
--Declare variables and set values:
DECLARE @operator_id int
SELECT @operator_id = [id] FROM msdb.dbo.sysoperators
WHERE name = 'SQLOperDBA'
--Update the affected rows with new operator_id:
UPDATE msdb.dbo.sysjobs
SET notify_email_operator_id = @operator_id
FROM msdb.dbo.sysjobs
LEFT JOIN msdb.dbo.sysoperators O
ON msdb.dbo.sysjobs.notify_email_operator_id = O.[id]
--check where clause , if not it is going to update all jobs
SELECT [name], [id], [enabled] FROM msdb.dbo.sysoperators
ORDER BY [name];
--Declare variables and set values:
DECLARE @operator_id int
SELECT @operator_id = [id] FROM msdb.dbo.sysoperators
WHERE name = 'SQLOperDBA'
--Update the affected rows with new operator_id:
UPDATE msdb.dbo.sysjobs
SET notify_email_operator_id = @operator_id
FROM msdb.dbo.sysjobs
LEFT JOIN msdb.dbo.sysoperators O
ON msdb.dbo.sysjobs.notify_email_operator_id = O.[id]
--check where clause , if not it is going to update all jobs
No comments:
Post a Comment