title: Speed up a UPDATE with SELECT query
body: <p>I have two tables:</p>
  
  <ul>
  <li>Table 1 has Episode and Code, with Episode as distinct.</li>
  <li>Table 2 has Episode and Code, but Episode is not distinct (other fields in the table, not relevant to the task, make each row unique).</li>
  </ul>
  
  <p>I want to copy Table 1's Code across to Table 2 for each episode.  The current code to do this is as follows:</p>
  
  <pre><code>UPDATE Table2
  SET Table2.Code = (SELECT TOP 1 Code FROM Table1 WHERE Episode = Table2.Episode)
  </code></pre>
  
  <p>This takes hours and hours.  (I don't know precisely how many hours, because I cancelled it at about the 20 hour mark.)  They <em>are</em> big tables, but surely there's a faster way?</p>