title: merge statement when not matched by source then insert to another table
body: <p>I have created two tables <code>customersrc</code> and <code>customertemp</code> with the columns:</p>
  
  <p><strong>customertemp</strong></p>
  
  <pre><code>ID  name    age addr    cityid  isactive
  34  Gi      24  Chennai     1   1
  </code></pre>
  
  <p><strong>customersrc</strong></p>
  
  <pre><code>CustomerId  CustomerName    CustomerAge CustomerAddress
  1            Gi               24    madurai
  2            Pa               23    Tirupur
  3            MI               27    Tirupur
  </code></pre>
  
  <p>Now I need to insert pa and mi data value to the temp table bcz it is not matched with the rows of <code>customertemp</code>. And the row gi data will be updated which was matched. </p>
  
  <p>I used the following <code>MERGE</code> statement</p>
  
  <pre><code>DECLARE @cityid INT SET @cityid=1
  
  MERGE Temp.dbo.customersrc as src_customer
  USING ( SELECT CustomerName,CustomerAge,CustomerAddress FROM customertemp) as temp_customer
  ON src_customer.name=temp_customer.CustomerName 
      AND
      src_customer.cityid=@cityid
  WHEN MATCHED THEN 
      UPDATE SET 
                  src_customer.age=temp_customer.CustomerAge,
                  src_customer.addr=temp_customer.CustomerAddress,
                  src_customer.isactive=1
  
  WHEN NOT MATCHED BY SOURCE THEN 
       UPDATE SET src_customer.isactive=0 ;  -- here i need the insert statement to insert in another table
  </code></pre>
  
  <p>Questions:</p>
  
  <ol>
  <li>is it possible to write insert statement inside the when not matched by source query?</li>
  <li>if it is not possible then how to achieve this using <code>merge</code>?</li>
  <li>in a simple set theory I need to put the customersrc(table_B)-customertemp (table_A). B-A value into the another or temp table. </li>
  </ol>