Asking exists

accessman2

Registered User.
Local time
Today, 00:08
Joined
Sep 15, 2005
Messages
335
Hi,

if exists(select * from information_schema.tables where Table_Name = '##tbl')
drop table ##tbl

Can we use this statement to drop temporary table?

Because when I run it, it cannot delete the temporary table.

So, we cannot check the temporary table.

Please let me know, thanks.
Thanks.
 
Temporary tables are dropped when the connection is dropped, so you should need to drop a temporary table, just close the connection
 
Single # temp tables are dropped with the connection, double # (Global Temp Tables) are seen by all connections and stay alive until they are dropped. Both reside in the tempdb database.

if exists(select * from tempdb.dbo.sysobjects where Name Like '##tbl%')
drop table ##tbl
 

Users who are viewing this thread

Back
Top Bottom