title: SQL Server: How to update a table with values from another table
body: <p>I have two tables.
  Users1:</p>
  
  <pre><code>UserID HolidayCity ValidFrom    ValidTo
  1      NULL        '1900-01-01' '2017-05-09'
  1      NULL        '2017-05-09' NULL
  2      NULL        '1900-01-01' '2017-05-09'
  2      NULL        '2017-05-09' NULL
  </code></pre>
  
  <p>Users2:</p>
  
  <pre><code>UserID CityID
  1      33
  2      55
  </code></pre>
  
  <p>I need to update HolidayCity column from the first table with the values in CityID column from the second table for each UserID, but only those records, <strong>where ValidTo IS NULL</strong>, so that the resulting table Users1 would be:</p>
  
  <pre><code>UserID HolidayCity ValidFrom    ValidTo
  1      NULL        '1900-01-01' '2017-05-09'
  1      33          '2017-05-09' NULL
  2      NULL        '1900-01-01' '2017-05-09'
  2      55          '2017-05-09' NULL
  </code></pre>
  
  <p>Can you please tell me how to do that?</p>