I am performing a load by using a temporary table in Microsoft SQL Server 2008 .
SELECT CAMPO1,
CAMPO2,
CAMPO3,
CAMPO4
INTO #TEMP
FROM DADOS
In the query, I use the following command, to check if the temporary table exists, if the table exists I do the DROP TABLE , as the example below.
IF OBJECT_ID('tempdb..#TEMP') IS NOT NULL
BEGIN
DROP TABLE #TEMP
END
After the executed execution the table continues to be created in tempdb
If executed only:
DROP TABLE #TEMP
The message is resumed:
Msg 3701, Level 11, State 5, Line 1
Can not drop the table '#TEMP', because it does not exist or you do not have permission.
You can only reload after disconnecting from the server.
I ask for help.