title: update column based on 2 keys sql server
body: <p>I have the following database tables</p>
  
  <ul>
  <li>Master Table – Contains PK Id column  for a data range</li>
  <li>Reference Table – A staging table with the data range that has the associated code</li>
  <li>Target Table – Table for which the Id column is to be inserted or updated based on the master and reference table</li>
  </ul>
  
  <hr>
  
  <pre><code>    Reference Table
            Code      From        To
            Abc45     200        400
            Cde78     0          128
            Fcde1     600        898
  
      Master Table
            Id        From        To
             1        1          100
             2        200        400
             3        0          128
             4        600        898
  
      Target Table
           Name      id      City      Country      Code
           West               B          CC         Fcde1
           East               V          GG         Cde78 
           North              T          TT         Abc45
           South              Z          YY         Abc45
  </code></pre>
  
  <p>Thanks In Advance</p>