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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.