Link to home
Start Free TrialLog in
Avatar of patd1
patd1Flag for United States of America

asked on

Stored proc not getting created because temp table already exists.

Using Sql Server 2012

I am using the following code where ever I am creating a temp table #wt3 in my stored proc code. But when I hit execute to create this SP I get the error mentioned below, at the second instance of creating this temp table:

IF (OBJECT_ID('tempdb..#wt3')) IS NOT NULL
			DROP TABLE #wt3	
SET ANSI_WARNINGS OFF
 SELECT TOP 0 * INTO #wt3 FROM db_template.dbo.DimTime

Open in new window


Error:
Msg 2714, Level 16, State 1, Procedure rollup_scores, Line 1463
There is already an object named '#wt3' in the database.

What am I missing?

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of patd1

ASKER

more research.