Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Conditional Logic
Message
 
 
To
17/06/2008 11:28:37
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01324772
Message ID:
01324777
Views:
10
This message has been marked as the solution to the initial question of the thread.
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
Previous
Reply
Map
View

Click here to load this message in the networking platform