Insert multiple values into stored procedure I have 2 System Stored Procedures.

1) exec spGetObsoleteUpdatesToCleanup

2) exec spDeleteUpdate @localUpdateID=000000

The first proc retrieves a column called "localUpdateID" with 30 000 rows.
In the second proc you have specify the retrieved row from the first proc at "@localUpdateID=000000"

Copying each one of the 30 000 rows and pasting it into the second proc will take forever.

I have tried:

1) exec spDeleteUpdate @localUpdateID = exec spGetObsoleteUpdatesToCleanup

2) exec spDeleteUpdate @localUpdateID IN ('00000', '00001')
You need to update your first stored procedure so it returns data using an OUT parameter.

You can create a temporary table variable that you will use to temporarily store the output IDs of your first stored procedure and then send them to the second.

It should end up looking something like this:

declare @OutputIdList table(localUpdateId int)
exec spGetObsoleteUpdatesToCleanup @OutputIdList=@OutputIDs OUTPUT
exec spDeleteUpdate select localUpdateId  from @OutputIdList


Microsoft has a blog post that explains how to give OUT parameters to stored procedures.

Here's some copy-pasted data from it.

    CREATE PROCEDURE Myproc
    @parm varchar(10),
    @parm1OUT varchar(30) OUTPUT,
    @parm2OUT varchar(30) OUTPUT
    AS
      SELECT @parm1OUT='parm 1' + @parm
     SELECT @parm2OUT='parm 2' + @parm
GO
DECLARE @SQLString NVARCHAR(500)
DECLARE @ParmDefinition NVARCHAR(500)
DECLARE @parmIN VARCHAR(10)
DECLARE @parmRET1 VARCHAR(30)
DECLARE @parmRET2 VARCHAR(30)
SET @parmIN=' returned'
SET @SQLString=N'EXEC Myproc @parm,
                             @parm1OUT OUTPUT, @parm2OUT OUTPUT'
SET @ParmDefinition=N'@parm varchar(10),
                      @parm1OUT varchar(30) OUTPUT,
                      @parm2OUT varchar(30) OUTPUT'

EXECUTE sp_executesql
    @SQLString,
    @ParmDefinition,
    @parm=@parmIN,
    @parm1OUT=@parmRET1 OUTPUT,@parm2OUT=@parmRET2 OUTPUT

SELECT @parmRET1 AS "parameter 1", @parmRET2 AS "parameter 2"
go
drop procedure Myproc