July 8, 2021 at 5:39 pm
Hi,
I am getting the below error for a query that runs inside the SSIS package. The Query does not have the symbol 'A'. Not sure from where that A is coming and erroring out the query. Please let me know your thoughts.
Error: Merge query to load sample to demo :Error: Executing the query "IFÂ OBJECT_ID('tempdb..##tmp')Â ISÂ NOTÂ NULL
  ..." failed with the following error: "Incorrect syntax near 'tempdb..##tmp'.".
query:
IF OBJECT_ID('tempdb..##tmp') IS NOT NULL
/*Then it exists*/
DROP TABLE ##tmp
July 8, 2021 at 6:10 pm
Can it be space or hidden character issue? I dont see anything when I paste this in notepad.
July 8, 2021 at 7:44 pm
Try
DROP TABLE IF EXISTS ##tmp
instead.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
July 8, 2021 at 9:49 pm
For fun, I tried running the query you had pasted and it runs fine on my system.
My guess is you copy-pasted that from another site that does some formatting on the text. My expectation is that wherever you copy-pasted it from it throws in some hidden characters that are used for colorizing the text or providing some level of formatting.
I would try either:
A - typing it out manually into SSMS and see if you get the same error
B - copy and paste the text into a text editor that won't retain formatting such as Notepad
Alternately, if you are copy-pasting or running a SQL query generated on Windows on a Linux machine (or generated on Linux and running on Windows), you will have different line terminators which MAY be causing some of the issues. Same thing applies to MAC if I remember right...
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply