Use one extra variable and do your processing outside the loop in the third case.
E.g.
declare @TestVar = 0
>I need to do something like the following in a query.
>
>
>
>DO WHILE looping through fetched rows and @MyVar changes value
>
>BEGIN
>
>IF @MyVar = 1
> BEGIN
> Do This
> END
>
>IF @MyVar > 1
> BEGIN
set @TestVar = 1
> Do This
> END
> >
IF @TestVar = 0
&& All your myVar are 1 (or less than 1), so you can try extra processing.
If it's not broken, fix it until it is.
My Blog