I'm dropping/creating a temp table many times in a single script
IF OBJECT_ID('tempdb..#uDims') IS NOT NULL
DROP TABLE #uDims
select * into #uDims from table1
.... do something else
IF OBJECT_ID('tempdb..#uDims') IS NOT NULL
DROP TABLE #uDims
select * into #uDims from table2 -- >> I get error here
.... do something else
IF OBJECT_ID('tempdb..#uDims') IS NOT NULL
DROP TABLE #uDims
select * into #uDims from table3 -- >> and here
.... do something else
when trying to run the script, I get
There is already an object named '#uDims' in the database.
on the second and third "select into..."
That is obviously a compile time error. If I run the script section by section, every thing will work well.
There are many workaround for this issue, but I want to know why SSMS is upset on that.