I apologize if I go back and insist on the issue of automatic generation script on a MERGE table,
for me is very useful in the design of datawarehouse ETL (for the Slowly changing dimensions) ...
create temporary tables containing the record to update or insert and through the construct sql MERGE (Vertica, Oracle , MSServer) I update the fact table without making any effort ... The automatic generation would help me in the frequent case of tables with a large number of fields.
See http://www.sqlservercentral.com/articles/MERGE/73805/
for detail
ES:
table_tmp and target_table has same structure, often target_table has a unique index or pk from wich
create the ON clause...
MERGE INTO target_table AS Target
USING table_tmp AS Source
ON ( Target.key_field = Source.key_field )
WHEN MATCHED
THEN UPDATE SET
data= target.data , data2=target.data2
WHEN NOT MATCHED
THEN INSERT ( key_field,dat,data2)
VALUES
( target.key_field,target.dat,target.data2 );