472,141 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,141 software developers and data experts.

how to drop a temporary table

hai,

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


thanks in advance.
Mar 5 '08 #1
2 1257
amitpatel66
2,367 Expert 2GB
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
nedu
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.

Similar topics

1 post views Thread by Rod Davis | last post: by
5 posts views Thread by Jay | last post: by
2 posts views Thread by robert | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.