Let me start out by saying I know I KNOW that these kind of loops are horrible and you shouldn't use them in Transact SQL. But, for some purposes (those purposes being irrelevant so don't ask me "what're you trying to do!?") ya just have to. I don't want to, but I gotta.
Anyway. Is there some way to have a while loop in T-SQL terminate on a complex conditional statement? like, in C# I'd just say while (i > -10 && i < 10) , because I want the loop to terminate when the sentinel value is between -10 and 10, but I just... can't figure out how to do it.
It's probably excruciatingly simple... or.. impossible. Please advise.
Right now, I've just got
WHILE @N <> 0
BEGIN
--code and such here
END
break, just as you would in C++ or C#.WHILE @N > -1 AND @N <10between -10 and 10?