title: OPENQUERY into temp table
body: <p>I'm trying to use OPENQUERY to get some data from MySQL, but I need to get the results into a temp table to manipulate. </p>
  
  <p>I've tried a couple of examples but getting the same error:</p>
  
  <pre><code>DECLARE @lastid int = (SELECT MAX(remoteid) FROM cdr)
  DECLARE @TSQL varchar(8000)
  SELECT  @TSQL = 'SELECT * FROM OPENQUERY([PBXA_MYSQL],''SELECT * INTO #tempcdr FROM asterisk.cdr WHERE id &gt; ''''' + CAST(@lastid as varchar(50)) + ''''''')'
  EXEC (@TSQL)
  
  SELECT * FROM #tempcdr
  </code></pre>
  
  <p>Cannot get the column information from OLE DB provider "MSDASQL" for linked server "PBXA_MYSQL".</p>
  
  <p>A normal select works fine, but select into has that error.</p>
  
  <p>Thanks</p>