title: Applying condition based on primary key match in sql tables
body: <p>I have two tables, tbl1 and tbl2 in Synapse. I need to insert entries from tbl2 into tbl1. The condition is if there's a primary key match(key can be id or name), then update the record. If there's no primary key match, then insert the new record. How can I do this using t-sql's exist condition. Do I need to use if..then..else and if so how?</p>
  <pre><code>SELECT a.PID, a.FName
  FROM dbo.tbl1 as a
  WHERE EXISTS
  (SELECT * 
    FROM dbo.tbl2 as b
    WHERE a.FName = b.FName)
  </code></pre>