title: SQL merge command on one table
body: <p>I am trying to get my head over <code>MERGE</code> sql statement. What I want to achieve is:</p>
  
  <p>Insert new values into the <code>CSScolorOrders</code> table but update <code>corQuantity</code> column if the record with <code>colID</code> and <code>ordID</code> already exist</p>
  
  <p>This is what I ended up with:</p>
  
  <pre><code>MERGE INTO CSScolorOrders AS TARGET 
  USING (SELECT * FROM CSScolorOrders WHERE ordID = 3) AS SOURCE 
  ON (SOURCE.colID = 1) WHEN 
  MATCHED THEN UPDATE SET corQuantity = 1 
  WHEN
    NOT MATCHED BY TARGET
    THEN INSERT (colID, ordID, corQuantity) VALUES (1, 3, 1);
  </code></pre>
  
  <p>Unfortunately it does not raise any exception so I do not know why it doesn't work.</p>