I need to use a select expression in a while loop and I use the below sample code:
declare @i integer
set @i=1
while (@i<10)
begin
select @i as m;
set @i=@i+1
END
this code returns 10 separate table! I want it to return all select results in one table… is that possible? if yes… how?
You can use a temp table or table variable for this.
Here’s how to do it using a temp table.
Very similar with a table variable