You don't say what result you're expecting.
However, I'd guess that you are expecting @A_counter to be redefined for each iteration of the outer loop. SQL variables aren't scoped like that, so you need to reset @A_counter to zero each time.
You may find this does what you want:
declare @B_counter int
declare @A_counter int
set @A_counter = 0
set @B_counter = 0
WHILE @B_counter <= 10 begin
WHILE @A_counter <= 10 begin
SET @A_counter = @A_counter + 1
print 'inner loop'
end
SET @B_counter = @B_counter + 1
SET @A_counter = 0
print 'outer loop'
end
On the other hand, you don't say what result you're after, or what you're getting, so I may be way off.
| [reply] [d/l] |
or simpler and more consistent:
declare @B_counter int
declare @A_counter int
set @B_counter = 0
WHILE @B_counter <= 10 begin
set @A_counter = 0
WHILE @A_counter <= 10 begin
SET @A_counter = @A_counter + 1
print 'inner loop'
end
SET @B_counter = @B_counter + 1
print 'outer loop'
end
| [reply] [d/l] |
This is extremely off-topic, as you may understand - better if you had to transfer your T-SQL knowledge over to Perl. Anyway, terce's efforts in answering would have been wasted without approval of your node, but please be more Perl-specific in the future.
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Don't fool yourself.
| [reply] |