Insert and Update Data With Merge Statement In MS SQL Server

The `MERGE` statement probably one of the most powerful features in SQL Server, especially for data engineering tasks. Using the `MERGE` statement, we can insert, update, or delete rows based the differences found in a source and a target tables. Very similar to UPSERT if you are coming from other database systems or you have worked with web APIs.
In this video, I want to go over how to use the `MERGE` statement in MS SQL Server.
► Buy Me a Coffee? Your support is much appreciated!
-------------------------------------------------------------------------------------------
☕ Paypal: www.paypal.me/jiejenn/5
☕ Venmo: @Jie-Jenn
💸 Join Robinhood with my link and we'll both get a free stock: bit.ly/3iWr7LC
► Support my channel so I can continue making free contents
---------------------------------------------------------------------------------------------------------------
🛒 By shopping on Amazon → amzn.to/2JkGeMD
👩‍💻 Follow me on Linked: / jiejenn
🌳 Becoming a Patreon supporter: / jiejenn
✉️ Business Inquiring: KZread@LearnDataAnalysis.org
#sql #sqlserver #dataengineering

Пікірлер: 5

  • @Krazy_Shorts
    @Krazy_Shorts Жыл бұрын

    Oh wow, didn't realize there was an OUTPUT option on the MERGE command. pretty handy!

  • @youngjuggler
    @youngjuggler Жыл бұрын

    This is great thank you so much! I love how much you prove your work and code.

  • @pahaadi_soul
    @pahaadi_soul Жыл бұрын

    Hey Jen.. thanks for the info , could you please help me in understanding where I can use this in ssis, do i have to make a stored procedure and call this merge statement or should I write the merge statement in a sql task in ssis

  • @user-gg2in2ri4c
    @user-gg2in2ri4c10 ай бұрын

    Hi, can you do one that troubleshoots when all the data you have defined in your insert statement doesn't correctly populate in the output on the second execution? It all correctly inserts on the first execution. However, on the second execution only one of those inserted values repopulates.

  • @jiejenn

    @jiejenn

    10 ай бұрын

    In most cases, you will rollback if the output is different from what the expected.