MERGE is a new feature introduce in SQL server 2008 version that provides an efficient
way to perform multiple DML operations. In previous versions of SQL Server, we
had to write separate statements to INSERT, UPDATE, or DELETE data based on
certain conditions, but now, using MERGE statement, we can include the logic of
such data modifications in one statement that even checks when the data is
matched, then just update it, and when unmatched, insert it. One of the most
important advantages of MERGE statement is all the data is read and processed
only once.
·
Manipulating
data in a single query for below parameters
·
Insert
the records if the record does not exists.
·
Update
the records if exists.
·
Delete
the record if exists.
Now we
will write MERGE process for tables created earlier. We will make sure that we
will have our three conditions discussed above are satisfied.
No comments:
Post a Comment