开发者

How can I exit an inner loop and continue an outer loop?

开发者 https://www.devze.com 2022-12-28 05:45 出处:网络
This is a follow-up to my previous question (Thanks for the answer, BTW!) If I have two loops: while @@fetch_status=0

This is a follow-up to my previous question (Thanks for the answer, BTW!)

If I have two loops:

while @@fetch_status=0
begin 
    set y=y+1
    set x=0
     while @@fetch_status=0
     begin
        x=y+1
        if y = 5
        'exit the second do while and back to the first do while --> y=y+1开发者_如何学C
     end
end

...how can I exit from the inner loop and continue the outer (see comment)?


I think you're looking for BREAK

Books online is a great resource for TSQL


WHy are you looping? In general looping and cursors are a bad thing in SQL server which is optimized to handle sets fo data not row by row processing. It is very possible that you don't need or want a loop at all.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号