in reply to (OT) T SQL Problem

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.

Replies are listed 'Best First'.
Re^2: (OT) T SQL Problem
by ikegami (Patriarch) on Sep 05, 2005 at 22:59 UTC
    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