I got stuck in a nested loop and would appreciate some advice.
Declare @monthNumber as Integer, @loopCounter as Integer
Set @monthNumber = 0
Set @loopCounter = 1
While @monthNumber <= 13 Begin
While @loopCounter <=100 Begin
@loopCounter = @loopCounter +1
End
@monthNumber = @monthNumber + 1
End
I've abbreviated my code to the sample above; I have two loops in my main SQL query. The inner loop is to identify different records in my table 100 times, and the outer loop is to basically add one extra month to the @monthNumber variable so that when the code runs, I return 100 records for each of the 13 months into one table. When I run the code, the first inner loop runs perfectly, but ends without continuing to the next month via adding a 1 to the @monthNumber. Any suggestions?