title: Pass a TABLE variable to sp_executesql
body: <p>I'm trying to pass a TABLE variable to the sp_executesql procedure:</p>
  
  <pre><code> DECLARE @params NVARCHAR(MAX)
   SET @params = '@workingData TABLE ( col1 VARCHAR(20),
                  col2 VARCHAR(50) )'
  
   EXEC sp_executesql @sql, @params, @workingData
  </code></pre>
  
  <p>I get the error: </p>
  
  <pre><code>Msg 156, Level 15, State 1, Line 1
  Incorrect syntax near the keyword 'TABLE'.
  </code></pre>
  
  <p>I tried omitting the column specification after 'TABLE'. I also tried to declare the table as a variable inside the dynamic SQL. But no luck...</p>
  
  <p>Seems to me that TABLE variables aren't allowed to be passed as parameters in this procedure?. BTW: I'm running MSSQL2008 R2.</p>
  
  <p>I'm not interested in using a local temp table like #workingData because I load the working data from another procedure:</p>
  
  <pre><code>INSERT INTO @workingData
       EXEC myProc @param1, @param2
  </code></pre>
  
  <p>Which I cannot do directly into a temp varaible (right?)...</p>
  
  <p>Any help appreciated!</p>