I sometimes have a problem running the script. I have a problem when using an application (which I did not write and therefore cannot debug) that runs scripts. This application does not return the full SQL Server error, but simply a description of the error, so I donβt know where exactly the error occurs.
I have an error only with this tool (it is a tool that sends queries directly to SQL Server using the DAC component), if I run the query manually in the management studio, I have no error. (This error, moreover, occurs only in a specific database).
My query looks something like this:
SELECT * INTO #TEMP_TABLE FROM ANOTHER_TABLE GO --some other commands here GO INSERT INTO SOME_OTHER_TABLE(FIELD1,FIELD2) SELECT FIELDA, FIELDB FROM #TEMP_TABLE GO DROP TABLE #TEMP_TABLE GO
The error I get is: #TEMP_TABLE is not a valid object
So for some reason, I suspect that the DROP statement is executed before the INSERT statement.
But AFAIK, when GO exists, the next statement is not executed until the previous is completed.
Now I assume this is not true in temporary tables ... Or do you have other ideas?
source share