title: How to update record in Insert into Select query
body: <p>I have this query which I am using to insert date in a table via select query.</p>
  
  <pre><code>INSERT INTO TEST
  SELECT * FROM (SELECT myDate, EmpCode, '2020-04-11 09:10:21', '2020-04-11 18:47:56') TBL
  WHERE NOT EXISTS (SELECT * FROM TEST WHERE myDate = TBL.myDate AND EmpCode = TBL.EmpCode)
  </code></pre>
  
  <p>The date this query might generate will be </p>
  
  <pre><code>Date          EmpCode  Check In               Check Out
  2020-04-11    101      2020-04-11 09:10:21    2020-04-11 18:47:56
  </code></pre>
  
  <p>So if I try to add same record it won't add in the <code>TEST</code> table but if I change the Values it will. Lets assume <code>EmpCode</code> is 101 and <code>myDate</code> is <code>GETDATE()</code>. Now for same date and same employee if I change the value of any column, here first <code>datetime</code> is <code>Check In</code> and second one is <code>Check Out</code>, so if I update the Check Out to <code>'2020-04-11 18:19:32'</code>, I want to not insert any row in the table but to update the existing row with new values. What are the changes I am supposed to make to make this work. The out after executing the query with updated value should be </p>
  
  <pre><code>Date          EmpCode  Check In               Check Out
  2020-04-11    101      2020-04-11 09:10:21    2020-04-11 18:19:32
  </code></pre>