SQL Server 2008 - Merge TSQL Statement

Опубликовано: 02 Декабрь 2024
на канале: DBATAG
8,912
4

Full Detailed Article for "Merge TSQL Statement" is available at :

http://sqlserver-training.com/sql-ser...

Follow us at more Updates at
-----------------------------------------
Website : http://sqlserver-training.com/
Twitter :   / dbatag  
Facebook :   / dbatag  
Linked In :   / dbatag  
================================

MERGE is a new DML statement in SQL Server 2008. MERGE allows you to perform simultaneous UPDATE, INSERT and/or DELETE operations on one table. There are new physical operators that combine these operations so that they can be performed in a single scan rather than multiple scans. Microsoft have implemented the ISO SQL 2003 and 2007 standard MERGE statement (as seen in Oracle and DB2) and added some extensions of their own.

Below are the three different matched clauses in MERGE:

WHEN MATCHED THEN
Rows that meet the criteria
WHEN [TARGET] NOT MATCHED THEN
Rows that do not match with another row in the target table
WHEN SOURCE NOT MATCHED THEN
Rows that do not match with another row in the source table


In summary, SQL Server 2008 introduces the MERGE statement which will allow users to perform insert, update and delete operations in a single statement.


Visit the following link for more details and SQL Server Tutorials
http://sqlserver-training.com/sql-ser...