Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a sql job step quit reporting failure

I have a sql job step

like this

Declare 
@Result varchar(255)

exec myprocedure
@Result = @Result output

What I want to do:
if @Result = 'Error' then mark the job as failed, how can I achieve that?

like image 331
CruelIO Avatar asked Feb 27 '23 15:02

CruelIO


1 Answers

Add this to the end of your script:

if @Result = 'Error'
    raiserror('The stored procedure returned an error',16,1)

And make sure that on the "Advanced" tab of the step properties, the "on failure action" is set to "Quit the job reporting failure"

like image 51
Ed Harper Avatar answered Mar 08 '23 11:03

Ed Harper