title: How to update linked table column from local SQL Server table
body: <p>I have a local SQL Server table and a remote linked MySQL table.  </p>
  
  <p>I need to pull email addresses from the local table to update the remote.</p>
  
  <p>This T-SQL statement works for a single update:</p>
  
  <pre><code>UPDATE openquery(SKYCOMLINK2, 'select tng_id, tng_account, tng_email from user_list where tng_account = 12345 and tng_status = ''A''') 
  SET tng_email = 'blah@blah.com';
  </code></pre>
  
  <p>What I want to do is, for every <code>RemoteTable</code> record with a status of 'A', I want to pull an email address from a local SQL Server table (example for a single record):</p>
  
  <pre><code>select email 
  from LocalTable 
  where id = 12345
  </code></pre>
  
  <p>So in English: for every active record in <code>RemoteTable</code> (could be multiples) look for a corresponding record in <code>LocalTable</code> of the same account number (one record per account number) and pull the email address from it to populate the matching records in <code>RemoteTable</code>. If it makes it easier, the <code>LocalTable</code> can be the driver as below (in quasi SQL-English):</p>
  
  <pre><code>update RemoteTable 
  set RemoteTable.email = LocalTable.email 
  where RemoteTable.accountNum = LocalTable.accountNum 
    and LocalTable.status = 'a' 
    and RemoteTable.status = 'a'
  </code></pre>
  
  <p>How can I do that? Thanks in advance.</p>