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

Job step indicates success when if fact failed, why? Expand / Collapse
Author
Message
Posted Friday, August 17, 2012 7:33 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, January 23, 2013 7:03 AM
Points: 158, Visits: 239
Hello,

I have a job with 4 steps in that didn't produce the results I'd expected. I checked the job history log and could see that all steps had ticks next them them, so was puzzled as to why this should be when I can clearly see that the records that should have been written were not.

I figured out what I'd done wrong, but am concerned as to why the job continued on despite a failure to INSERT new rows into a table.

The message section of the job log for the step in questiin reads as follows:

Executed as user: NT AUTHORITY\SYSTEM. Error details [SQLSTATE 01000] (Message 0)  898 [SQLSTATE 01000] (Message 0).  The step succeeded.
Post #1346544
Posted Friday, August 17, 2012 7:51 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, August 21, 2014 1:54 PM
Points: 1,430, Visits: 3,229
raotor (8/17/2012)

I figured out what I'd done wrong, but am concerned as to why the job continued on despite a failure to INSERT new rows into a table.


So, what was wrong with your code? Having a bug in your code doesn't always result in an error or exception that will make the job fail. Also, if you use try - catch you may be handling the errors yourself in some way.




The probability of survival is inversely proportional to the angle of arrival.
Post #1346551
Posted Friday, August 17, 2012 8:04 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, January 23, 2013 7:03 AM
Points: 158, Visits: 239
I had added a new NOT NULL column into a table which was being inserted into via a stored procedure in step 3 of the job. Since I had forgotten to update that stored procedure to include the new column within the INSERT statement, the thing bombed.

However, you are quite perceptive. I have indeed (after looking into the SP) used a BEGIN TRY .. CATCH block to catch any errors during the INSERT.

OK, do you know of a way to notify the job step that a failure has occurred so that I can have a job history that reflects any handled errors?

If not, will I need to remove the BEGIN TRY logic in order for this to happen.


Thanks.
Post #1346560
Posted Friday, August 17, 2012 8:05 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 10:18 AM
Points: 20,677, Visits: 32,271
Reraise the error CATCH block. About the only way I can think of handling it.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1346561
Posted Friday, August 17, 2012 8:16 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, January 23, 2013 7:03 AM
Points: 158, Visits: 239
Lynn Pettis (8/17/2012)
Reraise the error CATCH block. About the only way I can think of handling it.

Sorry, "Reraise" ?
Post #1346568
Posted Friday, August 17, 2012 8:20 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, August 21, 2014 1:54 PM
Points: 1,430, Visits: 3,229
He means use raiserror() in the catch block.



The probability of survival is inversely proportional to the angle of arrival.
Post #1346571
Posted Friday, August 17, 2012 8:29 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, January 23, 2013 7:03 AM
Points: 158, Visits: 239
sturner (8/17/2012)
He means use raiserror() in the catch block.

Ahhhh, thanks, I'll give that a go. :)
Post #1346575
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse