title: Merge - Only update if values have changed
body: <p>I am running a merge in SQL Server. In my update, I want to only update the row if the values have changed. There is a version row that increments on each update. Below is an example:</p>
  
  <pre><code>MERGE Employee as tgt USING 
  (SELECT Employee_History.Emp_ID
  , Employee_History.First_Name
  , Employee_History.Last_Name
  FROM Employee_History)
  as src (Emp_ID,First_Name,Last_Name)
  ON tgt.Emp_ID = src.Emp_ID
  WHEN MATCHED THEN 
      UPDATE SET
      Emp_ID = src.Emp_ID,
      ,[VERSION] = tgt.VERSION + 1 
      ,First_Name = src.First_Name
      ,Last_Name = src.Last_Name
  WHEN NOT MATCHED BY target THEN 
      INSERT (Emp_ID,0,First_Name,Last_Name)
  VALUES 
      (src.Emp_ID,[VERSION],src.First_Name,src.Last_Name);
  </code></pre>
  
  <p>Now, if I only wanted to update the row, and thus increment version, ONLY if the name has changed.</p>