I understand what the debugger is doing but I don't really agree with it, as the following should just surely work :
IF OBJECT_ID('TEMPDB..#extract') IS NOT NULL DROP TABLE #extract;
CREATE TABLE #extract(
x VARCHAR(100),
NumX_Rank NUMERIC(18,2),
NumG_Rank NUMERIC(18,2)
);
IF OBJECT_ID('TEMPDB..#extract') IS NOT NULL DROP TABLE #extract;
CREATE TABLE #extract(
x VARCHAR(100),
NumX_Rank NUMERIC(18,2),
NumG_Rank NUMERIC(18,2)
);
Error message is as follows:
Msg 2714, Level 16, State 1, Line 15 There is already an object named '#extract' in the database.
Please note - I have variables declared that I require throughout the script, i.e. the script is part of a stored procedure and the variables should have a scope across the whole proc.