• sknox (3/4/2015)


    archie flockhart (3/4/2015)


    Curious as to why the Break doesn't exit from the IF , as the referenced BOL page suggests that it should ? ( It clearly does work as stated, just not sure what the BOL reference to the IF ...ELSE statement refers to ? )

    Exits the innermost loop in a WHILE statement or an IF…ELSE statement inside a WHILE loop. Any statements appearing after the END keyword, marking the end of the loop, are executed. BREAK is frequently, but not always, started by an IF test.

    That's some pretty bad grammar, although technically it can be parsed to be correct.

    First note that it says "innermost loop" not "innermost block". So it won't exit an IF statement, because that's not a loop.

    Then "in a WHILE statement or an IF…ELSE statement inside a WHILE loop" indicates where a BREAK can be located, not what it acts upon.

    I agree that that's what it was intended to mean, but I think you are being over-generous to the BOL page author when you say that technically it can be parsed technically it can be parsed to be correct. It really needs fixing, perhaps by inserting the words "when exectuted" after the first occurrence of "loop".

    edit: fix quote tags

    Tom