阅读背景:

Using MERGE in SQL Server to insert, update and delete at the same time

来源:互联网 

Problem
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.  In this tip we will walk through how to use the MERGE statement and do this in one pass.In a typical data warehousing application,




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: