views:

144

answers:

2

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
     end
end

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

+1  A: 

I think you're looking for BREAK

Books online is a great resource for TSQL

SqlACID
ok..thanks..btw..we cant use enter here,can we?
leonita
@leonita: please see: http://stackoverflow.com/editing-help
Shog9
+1  A: 

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.

HLGEM
Why cant I give +5?
StingyJack