Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Step fails, but job reports success.


Step fails, but job reports success.

Author
Message
Erin.
Erin.
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1209 Visits: 558
I have a job that has multiple steps. Each step is set to 'Go to next step' on success or failure, except for the last step which is set to 'Quit the job reporting success/failure'. If the last step fails I get an email notification. If a step other than the last step fails I do not receive an email notification.

I am looking for a way to monitor jobs so I am aware when something like this happens. As anyone run into this? Any suggestions?

I am starting to look at the msdb database tables. I am thinking of setting up a Reporting Services report that queries these tables and emails me the results daily.

Does anyone have any ideas on how I could receive a failure notification instantly? Maybe a trigger? I have very little experience with triggers.
Marcin Gol
Marcin Gol
SSC-Enthusiastic
SSC-Enthusiastic (170 reputation)SSC-Enthusiastic (170 reputation)SSC-Enthusiastic (170 reputation)SSC-Enthusiastic (170 reputation)SSC-Enthusiastic (170 reputation)SSC-Enthusiastic (170 reputation)SSC-Enthusiastic (170 reputation)SSC-Enthusiastic (170 reputation)

Group: General Forum Members
Points: 170 Visits: 178
Maybe on failure you should use "Quit the job reporting success" ? Or maybe you can make a query against msdb.dbo.sysjobhistory ?
Animal Magic
Animal Magic
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1174 Visits: 13728
Do you still actually want the job to continue if one of the steps fail? if not then just change the failure action to "quit the job reporting failure". Assuming you do want the job to continue then you would have to start querying the system tables to retreive the step status'.
Erin.
Erin.
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1209 Visits: 558
I am using the following trigger I found on SQL Server Central.

USE [msdb]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

----------------------------------------------------------------------------
-- Object Type : Trigger
-- Object Name : msdb..trg_stepfailures
-- Description : Send notifications on job STEP failures (trigger)
-- Author : www.sqlservercentral.com By Kenneth Singer
-- Date : August 2009
----------------------------------------------------------------------------

CREATE trigger [dbo].[trg_stepfailures]
on [dbo].[sysjobhistory]
for insert
as
declare @strMsg varchar(400),
@strRecipient varchar(128),
@copyRecipient varchar(128),
@bccRecipient varchar(128)

set @strRecipient = 'recipient@company.com'
set @copyRecipient = 'recipient@company.com'
set @bccRecipient = ''recipient@company.com'

if exists (select * from inserted where run_status = 0 and step_name <> '(job outcome)')
begin
select @strMsg =
convert(char(10),'Server') + char(58) + @@servername +
char(10) +
convert(char(10),'Job') + char(58) + convert(varchar(50), sysjobs.name) +
char(10) +
convert(char(10),'Step') + char(58) + convert(varchar(50), inserted.step_name)+
char(10) +
convert(char(10),'Message') + char(58) + convert(varchar(150), inserted.message)
from inserted
join sysjobs
on inserted.job_id = sysjobs.job_id
where inserted.run_status = 0

raiserror (@strMsg, 16, 10) with log
exec msdb.dbo.sp_send_dbmail
@recipients = @strRecipient,
@copy_recipients = @copyRecipient,
@blind_copy_recipients = @bccRecipient,
@body = @strMsg,
@subject = 'Job Failure'

end
TRACEY-320982
TRACEY-320982
SSC Eights!
SSC Eights! (920 reputation)SSC Eights! (920 reputation)SSC Eights! (920 reputation)SSC Eights! (920 reputation)SSC Eights! (920 reputation)SSC Eights! (920 reputation)SSC Eights! (920 reputation)SSC Eights! (920 reputation)

Group: General Forum Members
Points: 920 Visits: 1014
I had this once where it would remain as Red x that it didn't run but it had run. I ended up just adding a new job and deleting it in the end...
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