Select and EXEC in a single statement – SQL server

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 =

  • Unable to access an instance of SQL Server 2008 R2 remotely
  • SQL Server JBDC Driver comparison
  • Using multiple Databases with single DbContext and Entites and generating Conn String at runtime
  • find sql table name with a particular column
  • tutorial on connecting c# to sql server
  • How to pass SQL values from one to multiple columns in SSRS Report?
  • 3 Solutions collect form web for “Select and EXEC in a single statement – SQL server”

    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

    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.

    You could wrap it all in a single SP.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.