title: Merge Statement throwing error
body: <p>I have a temp table  -  </p>
  
  <pre><code>   CREATE TABLE #TempMain(
        A int,
        B int,
        C int
     )
  </code></pre>
  
  <p>I run the following insertion just query once just to populate #TempMain</p>
  
  <pre><code>insert into #TempMain 
  
          SELECT 
                        A,
                        B,
                        C
                  FROM dbo.entity where RequestId = 1241 and ClassId = 25 and type=102
  </code></pre>
  
  <p>After that i am using Merge statement - </p>
  
  <pre><code>   MERGE #TempMain AS Target
              USING (
                      SELECT 
                            A,
                            B,
                            C
                      FROM dbo.entity where RequestId = 1241 and ClassId = 25 and type=102
                    ) AS Source ON (Target.B= Source.B AND Target.C= Source.C)
              WHEN MATCHED THEN 
              UPDATE SET Target.A= Source.A
              WHEN NOT MATCHED BY Target THEN 
              INSERT (A,B,C)
              VALUES (Source.A,Source.B,Source.C);
  
              select * from #temp1
  </code></pre>
  
  <p>When i run this merge statement query i get an error - </p>
  
  <p>The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.</p>
  
  <p>I am not able to understand the problem in my code. i looked for other similar errors i am still not able to fix this issue.</p>