tags:

views:

423

answers:

3

I have a temp table in a SP. I insert some values into it. I will need to then EXEC a second SP by sending in the values from the temp table. I would rather avoid having to use local variables.

DECLARE @tmp TABLE
(
  Name VARCHAR(200).
  Code INT
)

INSERT INTO @tmp
SELECT 'TEST', 100

EXEC MyProc
  @Name = --Here I send the values from temp
  @Code =
A: 

You could wrap it all in a single SP.

orthod0ks
+1  A: 

You can't, unless you're on SQL Server 2008 which allows table data types. Which can be used as stored proc parameters.

Otherwise frp SQL 2000/2005, for 10 rows in the temp table, you need loop through 10 inner stored proc calls.

gbn
+1  A: 

create an actual temp table #TempTable and not a @varibale table, and you can share it between parent and child stored procedures...

http://www.sommarskog.se/share_data.html#temptables

KM