I have a stored procedure that I want to call from within another, and then loop through the results. Sort of like using a cursor with a stored procedure rather than a SQL s
What Justin pointed out is what you have to do, but instead of doing
while @counter < (select max(idx) from @temp)
do this
declare @maxid int
select @maxid = max(idx), @counter = 1
from @temp
while @counter < @maxid begin
-- go on
set @counter = @counter + 1
end
Also, if declaring the table as @temp doesn't work you could declare it as #temp.