Can someone tell me the syntax to drop a temp table if it exists?
I've got this sql here:
IF EXISTS(SELECT [name] FROM tempdb..sysobjects WHERE [Name] = '#TempSummary')
BEGIN
DROP TABLE #TempSummary
END
but further down in my SP, when I try to create the table, I get an erro stating it already exists:
Server: Msg 2714, Level 16, State 6, Line 1
There is already an object named '#TempSummary' in the database.
Any clues?
I've got this sql here:
IF EXISTS(SELECT [name] FROM tempdb..sysobjects WHERE [Name] = '#TempSummary')
BEGIN
DROP TABLE #TempSummary
END
but further down in my SP, when I try to create the table, I get an erro stating it already exists:
Server: Msg 2714, Level 16, State 6, Line 1
There is already an object named '#TempSummary' in the database.
Any clues?