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


Job step indicates success when if fact failed, why?


Job step indicates success when if fact failed, why?

Author
Message
raotor
raotor
Say Hey Kid
Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)

Group: General Forum Members
Points: 710 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.

sturner
sturner
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4996 Visits: 3259
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.
raotor
raotor
Say Hey Kid
Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)

Group: General Forum Members
Points: 710 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.
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)

Group: General Forum Members
Points: 93035 Visits: 38955
Reraise the error CATCH block. About the only way I can think of handling it.

Cool
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)
raotor
raotor
Say Hey Kid
Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)

Group: General Forum Members
Points: 710 Visits: 239
Lynn Pettis (8/17/2012)
Reraise the error CATCH block. About the only way I can think of handling it.

Sorry, "Reraise" ?
sturner
sturner
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4996 Visits: 3259
He means use raiserror() in the catch block.

The probability of survival is inversely proportional to the angle of arrival.
raotor
raotor
Say Hey Kid
Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)Say Hey Kid (710 reputation)

Group: General Forum Members
Points: 710 Visits: 239
sturner (8/17/2012)
He means use raiserror() in the catch block.

Ahhhh, thanks, I'll give that a go. Smile
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