Full Detailed Article for "Merge TSQL Statement" is available at :
Follow us at more Updates at
Website : http://sqlserver-training.com/
Twitter : http://twitter.com/dbatag/
Facebook : http://facebook.com/dbatag/
Linked In : http://in.linkedin.com/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