Generate MERGE statements from a table

PRINT '-- ' + @table + ' -------------------------------------------------------------' --PRINT 'SET NOCOUNT ON;--' -- Set the identity insert on for tables with identities select @return = objectproperty(object


This is a companion discussion topic for the original entry at http://billg.sqlteam.com/2011/02/15/generate-merge-statements-from-a-table/