title: How to merge data from one table to another table in SQL Server
body: <p>I have table like this :</p>
  <p>Table A:</p>
  <pre><code>customerId     mobNo1    mobNo2    mobNo3
  -----------------------------------------
  123            999       997       987
  124            888       666       555
  </code></pre>
  <p>Table B:</p>
  <pre><code>customerId     mobNumbers    
  -------------------------
  123            999       
  123            997       
  123            987       
  124            888       
  124            666       
  124            555
  </code></pre>
  <p>I need to write a <code>MERGE</code> statement so that the data from tableA to get updated or inserted in to tableB</p>
  <p>This is what I tried:</p>
  <pre><code>MERGE tableB tgt
  USING (SELECT * FROM tableA) src ON src.customerId = tgt.customerId
  
  WHEN MATCHED THEN
      UPDATE 
          SET mobNumbers = src.mobNo1,
              mobNumbers = src.mobNo2,
              mobNumbers = src.mobNo3,
   
  WHEN NOT MATCHED THEN 
      INSERT (customerID, mobileNumbers)
      VALUES (src.customerID, src.mobNo1),
             (src.customerID, src.mobNo2), 
             (src.customerID, src.mobNo3);
  END
  </code></pre>
  <p>But this is not working - any idea how to achieve this?</p>