dnlnln / generate-sql-merge

Generate SQL MERGE statements with Table data
MIT License
337 stars 151 forks source link

@cols_to_exclude longer than 128 chars #77

Closed Kvasi closed 3 years ago

Kvasi commented 3 years ago

If I use more than 128 chars in @cols_to_exclude I get: The identifier that starts with ''InterestFreeDays','PaymentAccountID','MinDaysBeforeInterest','InterestPriceGroupID','InterestFromHoldDueDate','MinInterestAmoun' is too long. Maximum length is 128.

dnlnln commented 3 years ago

I can't actually reproduce this, would you mind providing an example call to sp_generate_merge?

Kvasi commented 3 years ago

EXEC sp_generate_merge @schema = 'dbo', @table_name = 'BillLocationCategory', @include_use_db = 0, @nologo = 1, @delete_if_not_matched = 0, @cols_to_exclude = "'InterestFreeDays','PaymentAccountID','MinDaysBeforeInterest','InterestPriceGroupID','InterestFromHoldDueDate','MinInterestAmount'"

dnlnln commented 3 years ago

Looks like an issue with the SQL, rather than the proc.

Try switching off QUOTED_IDENTIFIER i.e.:

SET QUOTED_IDENTIFIER OFF

EXEC sp_generate_merge @Schema = 'dbo', @table_name = 'BillLocationCategory', @include_use_db = 0, @nologo = 1, @delete_if_not_matched = 0, @cols_to_exclude = "'InterestFreeDays','PaymentAccountID','MinDaysBeforeInterest','InterestPriceGroupID','InterestFromHoldDueDate','MinInterestAmount'"

Or use single-quotes instead of double-quotes, and escape the string accordingly

Kvasi commented 3 years ago

Awesome, that worked.