alternate for :if (object_id('tempdb..#tablename') is not null) drop table #tablename

Posted by Skraghava under Sql Server on 2/10/2011 | Points: 10 | Views : 4940 | Status : [Member] | Replies : 5
Hi Team,

Do we have any alternate query for the below one, as this query is used many times.

if (object_id('tempdb..#tablename') is not null) drop table #tablename

Thanks and regards,
Raghavendra SK



Responses

Posted by: Madhu.b.rokkam on: 2/10/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
object_id function in SQL is one of the best function supplied by MS. So I think this is the best way to do that.

Regards
Madhu

Thanks and Regards
Madhu

Skraghava, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 2/10/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Skraghava


in my opinion it's aright way . .

Best Regard's
Prabhakar

Skraghava, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/10/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
This is the best one to use!!!

Thanks
Karthik
www.f5Debug.net

Skraghava, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/10/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
You can also get the result by searching this way

Select * from sys.objects where name like '#tablename%'

Regards
Madhu

Thanks and Regards
Madhu

Skraghava, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 2/10/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi

May I know, Why you looking for alternate for this approach ?

This is optimistics way!

Cheers
www.sqlserverbuddy.blogspot.com

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Skraghava, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response