SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Server Job Alert Notifications stopped working on a DB Server


SQL Server Job Alert Notifications stopped working on a DB Server

Author
Message
Welsh Corgi
Welsh Corgi
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10262 Visits: 4894
My SQL Server Job Alert Notifications stopped working on a DB Server.

I test Database Mail and it works but it does not send an email alert for jobs that I have set to notify on Job Failure.

What should I look at?

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Steve Jones
Steve Jones
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: Administrators
Points: 63698 Visits: 19115
I assume you have operators set up, right?

Do you manually a job and not get an email? Have you checked the sent stuff?

http://technet.microsoft.com/en-us/library/ms191278.aspx

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Welsh Corgi
Welsh Corgi
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10262 Visits: 4894
Steve Jones - SSC Editor (10/18/2013)
I assume you have operators set up, right?

Do you manually a job and not get an email? Have you checked the sent stuff?

http://technet.microsoft.com/en-us/library/ms191278.aspx


I am the only operator.

I setup this Server a few weeks ago and the alerts stopped working two days ago.

All of a sudden it stopped working.

I could not find an error that indicates the reason.

Perhaps I need to look harder.

Thanks!

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Welsh Corgi
Welsh Corgi
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10262 Visits: 4894
I wish that I knew why my jobs are not sending Job Notifications?

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
homebrew01
homebrew01
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4929 Visits: 9108
This does not answer your question, but you might find it useful. We have some jobs with multiple steps and if a middle step fails (eg step 4), the job continues to the next step (step 5, intentionally). However, if the final step succeeds the job itself shows as completed normally, not failed, so I would not get an email letting me know there was a problem.

I wrote this stored procedures to send me emails no matter what step fails. I think it is more useful than built in job notification.

I also have similar steps for my remote servers using LinkedServer.

CREATE PROCEDURE [dbo].[usp_JobStepFailedAlert] AS 
-- failed job steps

declare @RecCount int
DECLARE @tableHTML NVARCHAR(MAX) ;
declare @SubjectText varchar(150)
declare @BodyText varchar(150)

--=============================================================================
----- LOCAL SERVER
--=============================================================================

set @SubjectText = 'Failed Job Steps - MyServer ' + CONVERT(varchar(32), GETDATE(), 101) + ' @ ' + CONVERT(varchar(32), GETDATE(), 108)
set @BodyText = ' '

set @RecCount = 0

-- Get count of failed steps for specified time period
set @RecCount = (SELECT count(*)
FROM [msdb].[dbo].[sysjobhistory] h
join msdb..sysjobs j on j.job_id = h.job_id
where msdb.dbo.agent_datetime(h.run_date,h.run_time) > getdate() -1
and run_status <> 1 -- not succeeded
and h.step_id > 0) -- only look at actual steps

-- At least 1 failed step, so send email with query results showing job step info.
if @RecCount > 0 begin

SET @tableHTML = @BodyText +
N'<H1>Failed Job Steps</H1>' +
N'<table border="1">' +
N'<tr><th>Job Name</th><th>Step#</th><th>Step Name</th>' +
N'<th>Run Date</th><th>Server</th></tr>' +
CAST ( ( select td = j.name ,'', td = cast(step_id as char(7)), ' ',
td = step_name , '',
td = cast((msdb.dbo.agent_datetime(h.run_date, h.run_time)) as char(23)) , ' ' ,
td = [server] , ' '
FROM [msdb].[dbo].[sysjobhistory] h
join msdb..sysjobs j on j.job_id = h.job_id
where msdb.dbo.agent_datetime(h.run_date,h.run_time) > getdate() -1
and run_status <> 1 -- not succeeded
and h.step_id > 0 -- only look at actual steps
order by run_date desc, run_time desc, j.name, step_id
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'</table>' ;

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'DBA_Alerts',
@recipients= 'Me@MyCompany.com',
@subject = @SubjectText,
@body = @tableHTML,
@body_format = 'HTML',
@importance = 'High';
end





Welsh Corgi
Welsh Corgi
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10262 Visits: 4894
if @RecCount > 0 begin

Msg 156, Level 15, State 1, Procedure usp_JobStepFailedAlert, Line 27
Incorrect syntax near the keyword 'if'.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
homebrew01
homebrew01
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4929 Visits: 9108
Oooops. Misplaced bracket.... Corrected it

should be like this:

and h.step_id > 0) -- only look at actual steps



homebrew01
homebrew01
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4929 Visits: 9108
I should note the downside to this approach is that you only get notified when the code runs, not when the job fails. I have many morning jobs that run, so I have scheduled my "JobFailure" job to run every hour through the morning and early afternoon.



Welsh Corgi
Welsh Corgi
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10262 Visits: 4894
I was able to perform Test Database Mail without any problems.

I right clicked on SQL Server Agent > Properties >; Alter Settings > Clicked on the Alert Systems Tab. I checked Enable Mail Profile and specified the Operator, Mail System and Mail Profile.

I restarted the SQL Server Agent.

I tested and it and the mail notification works.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search