title: Update all but one of duplicate records in table in SQL Server
body: <p>I have a SQL Server table that has duplicate entries in one of the columns (<code>object_id</code>) e.g.:</p>
  
  <pre><code>+----+-----------+------------+
  | id | object_id | status_val |
  +----+-----------+------------+
  |  1 |         1 |          0 | 
  |  2 |         1 |          0 | 
  |  3 |         1 |          0 | 
  |  4 |         2 |          0 | 
  |  5 |         3 |          0 | 
  |  6 |         3 |          0 | 
  +----+-----------+------------+
  </code></pre>
  
  <p>I need to update all of their statuses except for one when there is duplication in the <code>object_id</code> column. So in the table above <code>object_id</code> 1 and 3 are duplicated. So I would want to change their <code>status_val</code> to 2, except one of the entries. The result would look like:</p>
  
  <pre><code>| id | object_id | status_val |
  +----+-----------+------------+
  |  1 |         1 |          0 | 
  |  2 |         1 |          2 | 
  |  3 |         1 |          2 | 
  |  4 |         2 |          0 | 
  |  5 |         3 |          0 | 
  |  6 |         3 |          2 | 
  +----+-----------+------------+
  </code></pre>
  
  <p>It doesn't matter which one of the duplicated rows has it's status updated.</p>
  
  <p>Any help would be appreciated.</p>