Merging Data

SQL Server 2008 introduces support for the MERGE statement. This statement allows you to identify a source and a target table and modify the target with data from the source, applying different modification actions (INSERT, UPDATE, DELETE) based on conditional logic. SQL Server implements the standard MERGE statement with a couple of extensions that are not part of the standard.

The MERGE statement has many uses both in OLTP and in data warehouse environments. For example, in an OLTP environment you can use it to merge data you get from an external source into an existing target table. In a data warehouse environment you can use it to apply incremental updates to aggregated data, process slowly changing dimensions, and so on.

In the ...

Get Inside Microsoft® SQL Server® 2008: T-SQL Querying now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.