dnlnln / generate-sql-merge

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

Error Occurs When Verifying the Existence of the 'hashedvalue' Column #95

Closed q0-0n closed 1 year ago

q0-0n commented 1 year ago

Issue Description: When attempting to add a 'Hashvalue' column on an Azure SQL Database called [database-with-a-hyphen], an error occurs if the database name contains hyphens. The error can be traced back to the following line:

https://github.com/readyroll/generate-sql-merge/blob/9e9ddd2472317d54d9a45ec81aaff5b3aa0131dc/master.dbo.sp_generate_merge.sql#L326

Suggested Solution: To mitigate this issue, it is recommended to enclose the database name using the QUOTENAME() function. This helps prevent syntax errors from arising during the execution of the SQL statement.

dnlnln commented 1 year ago

Thanks for the report, the issue is now fixed.

Just for context, the issue occurred on all SQL editions, i.e. both on-premise and Azure SQL.