title: SQL On Duplicate Key Update - On A Non-Primary-Key?
body: <p><strong>EDIT:</strong> Can anyone explain how I would use <strong>MERGE</strong> to solve this? Syntax is REALLY confusing me: <a href="https://technet.microsoft.com/en-us/library/bb522522(v=sql.105).aspx" rel="nofollow noreferrer">https://technet.microsoft.com/en-us/library/bb522522(v=sql.105).aspx</a></p>
  
  <p>I have a table called dbo.Customers_DefaultValues where basically if a customer forgets to input a value I will set that value in the database to a default specific to that customer. </p>
  
  <p><a href="https://i.stack.imgur.com/Y7YZ7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y7YZ7.png" alt="The database table"></a></p>
  
  <p>The key in the table is the Id. The FieldId is not unique to each customer so for example <strong>CustomerId = 1</strong> and <strong>CustomerId = 2</strong> can both have a <strong>FieldId = 11</strong>. What I want to do is that if I add a new value to a FieldId for a customer that already has a value - I want to update that value.</p>
  
  <p>I have read and tried with <strong>ON DUPLICATE KEY UPDATE</strong> but it keeps giving me errors. </p>
  
  <p><a href="https://i.stack.imgur.com/EaaaI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EaaaI.png" alt="enter image description here"></a></p>
  
  <p>Is there any way to solve this problem? </p>
  
  <p>Thanks in advance.</p>