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 2000 Forums
 Transact-SQL (2000)
 Dropping a temp table

Author  Topic 

AsimKhaliq
Yak Posting Veteran

94 Posts

Posted - 2003-12-10 : 22:58:08
hi
iam dropping a temp table , what i have to do is to check that if tyable exist then drop it. when I am running this command I dont have any error but the when still exists. Can some one help me. I cant use 'Use tempdb' thing

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[##temptab1]')
and OBJECTPROPERTY(id, N'IsTable') = 1)
drop Table[dbo].[##temptab1]

Thanks in advance
Asim

nr
SQLTeam MVY

12543 Posts

Posted - 2003-12-10 : 23:01:21
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb.[dbo].[##temptab1]')

But if other connections that use it are still open it won't drop.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

AsimKhaliq
Yak Posting Veteran

94 Posts

Posted - 2003-12-10 : 23:15:21
thanks
can i check, if user is connected.

Asim
Go to Top of Page
   

- Advertisement -