title: Where is a join processed when dealing with a linked server?
body: <p>In the example from SQL Server to <a href="https://docs.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine?view=sql-server-ver16#join-tables-from-a-linked-server" rel="nofollow noreferrer">join tables from a linked server</a>, it gives the following eample:</p>
  <pre><code>SELECT local.name AS LocalLogins, linked.name AS LinkedLogins  
  FROM master.sys.server_principals AS local  
  LEFT JOIN [SRVR002\ACCTG].master.sys.server_principals AS linked  
       ON local.name = linked.name;  
  GO  
  </code></pre>
  <p>How is the data passed back and forth between the two servers and where is the processing done? For example, does SQLServer run the following steps:</p>
  <ol>
  <li>Do <code>SELECT linked.name FROM [SRVR002\ACCTG].master.sys.server_principals</code></li>
  <li>Send the data back over the network to the local/master SQLServer, and for example, load that into a tmp table.</li>
  <li>Finish the query locally, for example:</li>
  </ol>
  <pre><code>SELECT local.name AS LocalLogins, linked.name AS LinkedLogins  
  FROM master.sys.server_principals AS local  
  LEFT JOIN tmp AS linked ON local.name = linked.name;  
  </code></pre>
  <p>Or how actually is the query executed?</p>