You could probably do it without the loop by structuring your output to match table definition like this:--structure output of outer proc to match target table and use the output as the insert values directlyif object_id('proc1') > 0 drop proc proc1GO--generate a random number of FOOs between 1 and 10create proc proc1 as set nocount ondeclare @tb table (foo int identity(1,1), col1 char(1))declare @recCount intSelect @recCount = floor(rand() * 10) + 1set rowcount @recCountinsert @tb (col1)select 'a' from sysObjectsset rowcount 0Select foo from @tbGO--create a Foo table if object_id('foos') > 0 drop table foosGOcreate table foos (foo int)GO--Insert into FOOs table as many foo records as are returned from proc1insert foosexec proc1--look at insert resultsSelect * from foosreturn--============================================================================--OR- to answer your question:/*declare @counter intSET @counter = 1WHILE @counter <= numRecordsBEGIN IF @var + @counter IS NOT NULL EXEC ('procTestInsert @foo = @var' + convert(varchar,@counter)END*/Be One with the OptimizerTG