Add this to the end of your script:
if @Result = 'Error'
raiserror('The stored procedure returned an error',16,1)
And make sure that the “Advanced” tab of the step properties has the “on failure” parameter set to “End Job Report Failure”
source
share