title: Passing temp table from one execution to another
body: <p>I want to pass a temp table from one execution path to another one nested in side it </p>
  
  <p>What I have tried is this:</p>
  
  <pre><code>    DECLARE @SQLQuery AS NVARCHAR(MAX)
  
      SET @SQLQuery = ' 
      --populate #tempTable with values   
      EXECUTE('SELECT TOP   (100)    * FROM ' + tempdb..#tempTable) 
  
      EXECUTE sp_executesql @SQLQuery
  </code></pre>
  
  <p>but it fails with this error message:</p>
  
  <blockquote>
    <p>Incorrect syntax near 'tempdb'</p>
  </blockquote>
  
  <p>Is there a another\better way to pass temporary table between execution contexts?</p>