title: SQL Server 2008 update table with values from another table
body: <p>Below you can see my simplified DB model:</p>
  <p><img src="https://i.stack.imgur.com/DXWr7.jpg" alt="enter image description here" /></p>
  <p>Due to an error there are only null-values in the column <strong>Job.location</strong> where the entries belong to a certain <strong>Plan</strong>. Therefore I want to update all Jobs associated with this Plan, setting <strong>Job.location</strong> to <strong>Location.name</strong> of the <strong>User</strong>, who owns this Plan.</p>
  <p>I tried this SQL query:</p>
  <pre><code>    update dbo.Job set location =
  
          (select name from dbo.Location as loc where
  
             loc.objectid = objectid  and loc.user_id in 
  
             (select userid from dbo.[Plan] as p where p.planid = 20))
  
          where planid = 20
  </code></pre>
  <p>However, the result is always: <em>0 rows affected</em>. The subqueries itself work correctly.</p>
  <p>How can I achieve that all Jobs with a certain planid are affected?</p>