briangriffin
Programmer
Trying to populate a variable table with 24 records for each client (for now I've hardcoded the outer loop to execute 4 times). The inner loop executes 24 times as it should, but the outer loop only executes once,and I'm not sure why:
Code:
declare
@v_hourcount int,
@v_loccount int
set @v_hourcount = 1
set @v_loccount = 1
while @v_loccount <= 4
BEGIN
while @v_hourcount <= 24
BEGIN
insert into @v_results (location, drawnhour)
select b.location, @v_hourcount
from @v_locations b
where b.locid = @v_loccount
set @v_hourcount = @v_hourcount + 1
END
set @v_loccount = @v_loccount + 1
END
select * from @v_results
Thanks in advance for your help.