By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,288 Members | 1,695 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,288 IT Pros & Developers. It's quick & easy.

how to drop a temporary table

P: 6
hai,

I want to drop a temporary table if it exists. How can we do this.


thanks in advance.
Mar 5 '08 #1
Share this Question
Share on Google+
2 Replies


amitpatel66
Expert 100+
P: 2,367
hai,

I want to drop a temporary table if it exists. How can we do this.


thanks in advance.
please post what you have tried so far?
Mar 5 '08 #2

P: 65
Hi,

You shall use the below code . .

if exists (select * from dbo.sysobjects where id = object_id(N'tempdb..#temp1') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
Begin
drop table [#temp1]
print 'dropped'
End
Else
Begin
print 'No Such tables'
End

Regards,
Nedu. M
Mar 5 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.