开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜