113983
Programmer
- Jul 28, 2008
- 26
I have need to write program something like below
if @pnumber=1
begin
select * into #all from table1 where code = 9
end
else
begin
select * into #all from table1 where secondcode=99
end
when I try this I get #all already exists even though I am executing the else portion of above.
"There is already an object named '#all' in the database."
Is there a way around this?
if @pnumber=1
begin
select * into #all from table1 where code = 9
end
else
begin
select * into #all from table1 where secondcode=99
end
when I try this I get #all already exists even though I am executing the else portion of above.
"There is already an object named '#all' in the database."
Is there a way around this?