General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Can't create a procedure
I am trying to create a procedure with a simple IF statement included. What I want to accomplish is this:
If x=y
begin
select * into #temp from tableA where x=y
...
end
else
begin
select * into #temp from tableA where x=z
...
end
When I try to recompile the procedure I recieve the following message:
"There is already an object named '#temp' in the database."
Why is it creating the temporary table when I try to compile the procedure? And/or what can I do to get around this? The subsequent coding of the procedure needs to reference the one temporary table.
Thanks in advance
Kelly
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only