Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Drop table #tmp problem

Author  Topic 

chih
Posting Yak Master

154 Posts

Posted - 2008-03-24 : 20:01:12
Hi Everyone,

If i execute
select * into #tmp from member
select * from #tmp
drop table #tmp
select * into #tmp from member
select * from #tmp

it will say 'There is already an object named '#tmp' in the database.
'

Why?? I have droped the table.

thanks in advance,

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-03-24 : 22:26:32
Have to run 'drop table #tmp' in its own batch.
Go to Top of Page

QAZAFI
Yak Posting Veteran

50 Posts

Posted - 2008-03-24 : 23:22:09
Hi Dear
This is the solution to your question. I have just put a “GO” after the drop statement and it will do the magic :). “GO” Signals the end of a batch of Transact-SQL statements to the SQL Server utilities

select * into #tmp from module
select * from #tmp
drop table #tmp
GO
select * into #tmp from module
select * from #tmp
Go to Top of Page

chih
Posting Yak Master

154 Posts

Posted - 2008-03-24 : 23:30:38
Thank you
Go to Top of Page
   

- Advertisement -