dnlnln / generate-sql-merge

Generate SQL MERGE statements with Table data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Way to use non-static values as source?

paschott opened this issue · comments

I appreciate the work on this, but is it possible to have a way to make the source be a "SELECT columns FROM sourceTable" type query instead of using static values? I'd like to be able to dev this on a test system and push to any other system where those values could potentially be different depending on what customers have put in the tables.

That would be a great addition. Tables with millions of rows won't work with this script... memory exceptions or the generated script is gigantic

I've just created a pull request that may solve this problem #37

As @eugeneniemand said, I believe that #37 resolves this issue so I'll close it out now.

To select directly from the source table when the MERGE statement is executed (rather than including static within a VALUES clause as the source), set the newly-added @include_values to 0:

EXEC sp_generate_merge 'AddressType', @schema = 'Person', @include_values = 0, @target_table = 'Person_Copy'