I have an SP in which I create a temporary table in the following way:
SELECT *
INTO #TABLA_AR
FROM TRABAJADOR
WHERE AREA IN (3,5,9,15)
The SP has several processes and if it fails in any process after creating the temporary table, when correcting the error and executing it it fails because the temporary table already exists
All temporary tables are stored in the database named
tempdb
, so you should look for your temporary table there before trying to create it:Use this before creating your temporary table
This snippet validates if the temporary table already exists. If it exists remove it, this way you could execute the rest of the code
Hello, I think it would be like this:
you put this instruction in your SP and you can recreate it, is that what you mean?