SQL Server 2008 Merge Statement Multiple Match Conditions
<p>I am attempting to bring in claim data in an incremental manner. I am matching source and target on <code>System</code> (<code>varchar</code>) and <code>ClaimNum</code> (<code>varchar</code>), with a hash of the other columns to check for changes.</p>

<p>I have my merge statement (simplified):</p>

<pre><code>MERGE target
USING source ON target.System = source.System
             AND target.ClaimNum = source.ClaimNum

WHEN MATCHED AND target.HashValue &lt;&gt; source.HashValue
THEN {update claim record data}

WHEN MATCHED AND target.HashValue = source.HashValue
THEN {update claim record as "checked"}

WHEN NOT MATCHED
THEN {insert new claim record}
</code></pre>

<p>However, I can't have 2 matched conditions. How else can I accomplish this with a merge statement?</p>

<p>This is being used on SQL Server 2008.</p>