I have an stored procedure of this format
if(condition 1)
begin
(
-----
-----
select into #temp1
----
drop #temp1
)
end
if(condition 2)
begin
(
-----
-----
select into #temp1
----
drop #temp1
)
end
now when the above stored procedure is execute it shows me an error that:
"There is already an object named '#temp1' in the database."
When I modify the stored procedure like,
if(condition 1)
begin
(
-----
-----
select into #temp1
----
drop #temp1
)
end
if(condition 2)
begin
(
-----
-----
select into #temp2
----
drop #temp2
)
end
It works good.But I want to optimize this because of creating too many temporary tables.
Can anybody help me on this?