check for existence of table in tempdb

  • How does one check for the existence of a named table in the tempdb. Using 'exists' or ' not exists' appears to only work if the table DOES exist. When the table does NOT exist it appears that Analyzer/T-Sql simply issues an error message and then quits. In my script I am setting up a temptable to carry info forward to subscripts. I need to verify that the temptable does not exist at the outset.

    Thanks for your help..

    As you can probably tell, I am somewhat of a NEWBIE with SQL Server and am stuck with using SQL Server 2000 for now. Our current main production DB is Oracle.......(still)

     

  •   IF object_id('tempDB..#test') IS NOT NULL  

        drop table #test

  • Thank you Pam! I've found another way, but yours appears to be much easier!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply