title: Query global temp table on a linked server
body: <p>I have seen all of the references on how to query two different tables on two different SQL servers, and I understand how it is to be implemented. However, the command doesn't seem work with temporary tables created with the <code>##</code>.</p>
  
  <p>If I write a join on one server, and it references one temp table on that server, and one temp table on the other server, SQL Server assumes that because the <code>##</code> is in the command, it automatically looks at the local server's <code>tempdb</code>, not the remote one. I also cannot use <code>OPENROWSET</code> at this time because the feature has been disabled and I have to get approval to turn it back on.</p>
  
  <p>So my question is there a way that I can reconfigure this command to recognize which <code>tempdb</code> to look at?</p>
  
  <pre><code>SELECT * 
  FROM (##mytemptable1 Demog 
  INNER JOIN MyServer.tempdb.dbo.##mytemptable2 PeakInfo ON (Demog.SAMPLE_NO = PeakInfo.SampleNum)  AND  (Demog.JOB_NO = PeakInfo.JobNum) )
  ORDER BY PeakInfo.JobNum, PeakInfo.SampleNum,   PeakInfo.Replicate ,PeakInfo.Reinjection ,PeakInfo.PeakNameCustSort
  </code></pre>