我如何使SQL作业步骤退出报告失败 [英] How do I make a sql job step quit reporting failure

查看:166
本文介绍了我如何使SQL作业步骤退出报告失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个sql作业步骤

I have a sql job step

像这样

Declare 
@Result varchar(255)

exec myprocedure
@Result = @Result output

我想做什么:
如果@Result ='Error'然后将作业标记为失败,我该如何实现?

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

推荐答案

将其添加到脚本末尾:

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"

这篇关于我如何使SQL作业步骤退出报告失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆