Home Forums SQL Server 7,2000 T-SQL union on the output of two stored procedures RE: union on the output of two stored procedures

  • Just Create A tempTable with the structure of the Recordset returned by the sp and use the insert exec construct like:

    declare @TimesToRun int

            ,@blkidM int

            ,@blkid1 int

            ,@blkid2 int

            ,@blkid3 int

     

     

    set @TimesToRun = 3

    set @blkid1 = 218645

    set @blkid2 = 218646

    set @blkid3 = 218647

    set @blkidM = @blkid1

     

     Create Table #T (fld1 ,fld2 ,fld3..)

     

    while @TimesToRun > 0

     

    begin

     

    INSERT #T (fld1 ,fld2 ,fld3..) execute dbo.DensityGrad @blkid = @blkidM

     

    set @TimesToRun = @TimesToRun – 1

     

    set @blkidM = @blkid2

     

    end

     

    Select * from #T1

     

    you will also have to change your parameter to use a list of values sepparated by a comma or with equal spacing so that you can automate the parameter passing too!

     

    HTH

     


    * Noel