Siddhesh Chavan
What is use of Merge in SQL?

What is use of Merge in SQL?

By Siddhesh Chavan in SQL Server on Jun 08 2024
  • Sreenath Kappoor
    Jun, 2024 19

    Merge statement is a powerful feature that allow us to perform insert, update and delete operations in a single operation based on a condition.

    It is particularly useful for synchronizing data between tables or performing upsert operations.(update if exists, insert if not exists)

    Syntax:

    MERGE INTO target_table AS target
    USING source_table AS source
    ON merge_condition
    WHEN MATCHED THEN
    UPDATE SET column1 = value1, column2 = value2, …
    WHEN NOT MATCHED BY TARGET THEN
    INSERT (column1, column2, …)
    VALUES (value1, value2, …)
    WHEN NOT MATCHED BY SOURCE THEN
    DELETE;

    • 1
  • Shashidhar R
    Oct, 2024 26

    perform INSERT , UPDATE or DELETE rows in one query using

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS