Sunday, March 22, 2009

MERGE SQL Statement in SQL Server 2008

In a typical data warehousing application, quite often during the ETL cycle you need to perform INSERT, UPDATE and DELETE operations on a TARGET table by matching the records from the SOURCE table. For example, a products dimension table has information about the products; you need to sync-up this table with the latest information about the products from the source table. You would need to write separate INSERT, UPDATE and DELETE statements to refresh the target table with an updated product list or do lookups. Though it seems to be straight forward at first glance, but it becomes cumbersome when you have do it very often or on multiple tables, even the performance degrades significantly with this approach. With the new MERGE SQL statement in SQL Server 2008 you can perform all these operations in one pass.
Refer this link to learn more details about it.

No comments:

Post a Comment