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

How do I detect a local temp table

P: n/a
I sometimes begin a script like this:

if exists (select * from sysobjects where name = 'T_Table') drop table

select * into T_Table (etc)

How do I do this with a local temp table? I thought of this:

if exists (select * from sysobjects where name like '#Temp_%') drop
table #Temp

.... but that seems dangerous to me. Is there a better way?


Nov 14 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a
I normally use this approach which works well:

IF OBJECT_ID(N'tempdb..#Temp', N'U') IS NOT NULL
Plamen Ratchev
Nov 14 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.