Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL Server Job Alert Notifications stopped working on a DB Server Expand / Collapse
Author
Message
Posted Friday, October 18, 2013 9:06 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 9:19 AM
Points: 4,228, Visits: 4,280
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/

Post #1506210
Posted Friday, October 18, 2013 9:36 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 2:27 PM
Points: 33,267, Visits: 15,434
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
Post #1506232
Posted Friday, October 18, 2013 10:44 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 9:19 AM
Points: 4,228, Visits: 4,280
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/

Post #1506271
Posted Sunday, October 20, 2013 8:24 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 9:19 AM
Points: 4,228, Visits: 4,280
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/

Post #1506471
Posted Sunday, October 20, 2013 9:11 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 1:06 PM
Points: 2,829, Visits: 8,479
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




Post #1506476
Posted Sunday, October 20, 2013 11:49 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 9:19 AM
Points: 4,228, Visits: 4,280
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/

Post #1506489
Posted Sunday, October 20, 2013 12:37 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 1:06 PM
Points: 2,829, Visits: 8,479
Oooops. Misplaced bracket.... Corrected it

should be like this:

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



Post #1506495
Posted Tuesday, October 22, 2013 1:47 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 1:06 PM
Points: 2,829, Visits: 8,479
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.


Post #1507338
Posted Friday, October 25, 2013 6:42 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 9:19 AM
Points: 4,228, Visits: 4,280
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/

Post #1508436
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse