Hello @Vaibhav B ,
Thanks for the question and using MS Q&A platform.
As we understand the ask here is how the MERGE operatios works, please do let us know if its not accurate.
You said
After merge Operation The count should show updated 1 and inserted 1
But the snashot says Updated -3
Let me share what i think is going on .
We are clear about the INSERT part , as we have 1 ID ( ID 4 , Viraj ) which is not in the dlt_salary table and so the INSERT happens for this record .
For the update , the dlt_salary and df_source have 3 records which are common ( matched i should say ID , 1,2,3 ) and so three records are updated .
Behind the scene MERGE command is combination of INSERT and UPDATE statement on match records .
Please do let me if you have any queries.
Thanks
Himanshu
- Please don't forget to click on or upvote button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
- Want a reminder to come back and check responses? Here is how to subscribe to a notification
- If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators