Can I have a CASE statement within a WHILE loop?

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-05-26T19:00:30Z Indexed on 2010/05/26 19:21 UTC
Read the original article Hit count: 219

Filed under:
|
|

This is what I'm doing:

while (@counter < 3 and @newBalance >0)
begin   
CASE
when  @counter = 1 then  ( @monFee1 = @monthlyFee, @newBalance = @newBalance-@fee)
when  @counter = 2 then  ( @monFee2 = @monthlyFee, @newBalance = @newBalance-@fee)
END
@counter = @counter +1
end

I get this error:

Incorrect syntax near the keyword 'CASE'.

No idea why. Please help!

© Stack Overflow or respective owner

Related posts about sql

Related posts about case