I have sql that will check if a temp table exists. If the table does exist I need to delete it(Which I suppose means to drop it), because immediately after deleting it, I want to recreate it. The code is not working, as I keep getting an error message: "There is already an object named #TempTable in the database. Can someone tell me what is wrong with the code?
IF object_id('#TempTable') is not null
DROP TABLE #TempTable
CREATE TABLE #TempTable