从存储过程退出 [英] Exit from a stored procedure

查看:155
本文介绍了从存储过程退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个循环和一个条件.如果条件匹配,那么我想停止或退出存储过程.怎么做?

I have some loop and a condition. If codition is matched then I want to stop or exit from the stored procedure. How to do that?

while @@fetch_status=0
    begin
        if x=0
            'exit stored procedure
    end

推荐答案

如果您使用的是Microsoft Sql Server,则可以使用Return语句

if you are using Microsoft Sql Server than you can use Return Statement

while @@fetch_status=0 begin if x=0 return; end

这篇关于从存储过程退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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