title: Query to join two tables in Sql Server
body: <p>I have the two tables:</p>
  
  <pre><code>TABLE1 (currency nchar(3), seq int)
  TABLE2 (code, currency nchar(3), seq int, value money)
  </code></pre>
  
  <p>Sample data for <code>TABLE1</code></p>
  
  <pre><code>currency    seq
  USD          1
  EUR          2
  CNY          3
  GBP          4
  </code></pre>
  
  <p>Sample data for <code>TABLE2</code></p>
  
  <pre><code>code     currency       seq    value
  111       USD            1     650,90
  111       AED            5     330,80
  
  222       USD             1     540,90
  222       GBP             4     778,40
  222       EUR             2     290,30
  </code></pre>
  
  <p>Now I need to add to <code>TABLE2</code> currencies from <code>TABLE1</code> but only those, that are missing in <code>TABLE2</code> for certain <code>code</code>.</p>
  
  <p>Sample output:</p>
  
  <pre><code>   code    currency     seq    value
     111       USD         1     650,90
     111       AED         5     330,80      --this currency should stay even it is not in TABLE1
     111       EUR         2     NULL        --this currency was missing for code 111
     111       CNY         3     NULL        --this currency was missing for code 111
     111       GBP         4     NULL        --this currency was missing for code 111
  
     222       USD         1     540,90
     222       GBP         4     778,40
     222       EUR         2     290,30
     222       CNY         3     NULL       --this currency was missing for code 222
  </code></pre>
  
  <p>I could show my attempts to build a query but they all fail.</p>