title: SQL Server update - is ther a way to avoid duplicates by skipping rows?
body: <p>I am trying to move data from one locale to another if is does not already exist in the second locale.  The statement I am using to do so, takes 20 hours to execute, so I would appreciate any ideas on how to do this more efficiently.</p>
  
  <pre><code>update table 
  set localeid = 3 
  where localeid = 1 
    and not exists 
            (select id from table as b where localeid = 3 and id = b.id)
  </code></pre>
  
  <p>I was wondering if there is some way to use a constraint and have SQL skip rows where the constraint is violated rather than fail the whole update. In this case the constraint would be to make <code>id,localeid</code> primary keys.</p>
  
  <p>Can this be done?</p>
  
  <p>p.s. the indexes required to optimize this query are in place, but it still takes forever due to the massive size of this database which has over 70 million entries.</p>