I think you missunderstand the MERGE query in SQL2008. MERGE is a shortcut for performing insert, update, or delete operations on a target table based on the results of a join with a source table, all in a single query. It operates on rows not on columns. However your script is interesting for the problem it solves and it should be useful even in SQL2008.