Error formatting MERGE statement in WHEN NOT MATCHED BY
opc.three
Posts: 17 New member
WHEN NOT MATCHED BY SOURCE AND SomeID = @SomeID THEN DELETEThe above code inside a MERGE statement is giving SQL Prompt problems causing it to show a Syntax error underlining column SomeID.
Comments
Thanks for your post.
I was not able to replicate the issue so it will be really helpful if you email me the complete query?
The red underline is the native SSMS feature and not SQL Prompt's. The setting is here: in SSMS navigate to Tools --> Options --> Text Editor --> Transact SQL --> Intellisense do you have the option "Underline errors" checked here? If yes this is what is triggering in your case.
Also if you get an error from SQL prompt please let me know the detailed version as well? (In SSMS navigate to SQL prompt --> Help --> About SQL Prompt)
I will email you so you can reply me with the complete query that fails.
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
The use of the English language in the error message is dreadful however I made sure to type it in exactly as it is shown, i.e. that is the exact error message shown.
By me adding a "target."-qualification to the column SomeID in my original code the error goes away however this should not be necessary because SQL Server does not require it, i.e. it is unambiguous so SQL Prompt should not complain. By definition "WHEN NOT MATCHED BY SOURCE" any additional predicates can only be referring to the target otherwise the predicate would be trivial.
I have overcome the issue but I still think SQL Prompt should relax on this validation to match SQL Server.
Sorry for the confusion, we think we’ve now been able to reproduce this issue and we’ll look into improving this.
Thanks
Ali
This issue should now be fixed in the latest beta (7.1.0.234): https://forums.red-gate.com/viewtopic.php?f=169&t=78967
Please let us know if you have any issues with this build.
Thanks
Ali