Re: Checking if a table exists, so that it may be dropped before recreating it

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Trey Walpole (treyNOpole_at_SPcomcastAM.net)
Date: 05/06/04


Date: Thu, 6 May 2004 16:17:17 -0500

if you want to avoid using the system tables:

if exists (select * from INFORMATION_SCHEMA.TABLES where
TABLE_NAME='theTable' and TABLE_TYPE='BASE TABLE')
    drop table theTable

"Dr Tarheel" <anonymous@discussions.microsoft.com> wrote in message
news:615F961F-D6A8-42D2-AB59-58584CB0B122@microsoft.com...
> It may be argued that truncating the original and running an INSERT would
be more efficient, but I am required to create the table afresh each time.
There will be some occasions where the table may be already dropped. If that
is the case, I'd like to skip the DROP TABLE command and go straight to the
SELECT. I understand I can query sysobjects to determine if the table
exists, but what is the most straight forward way to implement this. A code
snippet would be a world of help.
>
> Thanks,
> Dr Tarheel



Relevant Pages

  • Re: JV and MS - Suzuka 1997: Remember this...?
    ... At last you admit JV turned into MS path as MS sought to avoid him. ... straight before being up to speed. ... Did Ferrari even complain? ...
    (rec.autos.sport.f1)
  • Re: White van, mobile phone man
    ... two lanes of traffic. ... I just managed to avoid him. ... straight across my bows oblivious of me and those behind ... for vehicles to pass if they crawl past each other - so I'm taking it ...
    (uk.rec.driving)
  • Re: White van, mobile phone man
    ... Pulled straight out of a petrol station making a right turn dodging two lanes of traffic. ... No way out except for me to duck out of his way into some bodies drive to avoid the crunch. ... the rest of us know that you spotted the danger and avoided the danger. ... So there was no incident apart from van mans driving. ...
    (uk.rec.driving)
  • Re: White van, mobile phone man
    ... and realised what arseholes they are and adjusted your driving just in case :-) ... No he isn't he is going all the way round via L1 and cuts straight across my bows oblivious of me and those behind me. ... No way out except for me to duck out of his way into some bodies drive to avoid the crunch. ... By luck, good judgement, or skill I do manage to dodge all of them on a daily basis and far too frequently - but one day 'white van man on the phone' is going to meet 'white van man on the phone' coming the opposite way. ...
    (uk.rec.driving)
  • Re: Some Handloads that make the German Luger actually work.
    ... My grip is firm and my arms are straight to ... avoid this problem. ... Both of these pistols are known for having ...
    (rec.guns)