Re: Checking if a table exists, so that it may be dropped before recreating it
From: Trey Walpole (treyNOpole_at_SPcomcastAM.net)
Date: 05/06/04
- Next message: Dr Tarheel: "Re: Checking if a table exists, so that it may be dropped before recreating it"
- Previous message: Hugo Kornelis: "Re: Replace function problem"
- In reply to: Dr Tarheel: "Checking if a table exists, so that it may be dropped before recreating it"
- Next in thread: Tim S: "Re: Checking if a table exists, so that it may be dropped before recreating it"
- Reply: Tim S: "Re: Checking if a table exists, so that it may be dropped before recreating it"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Dr Tarheel: "Re: Checking if a table exists, so that it may be dropped before recreating it"
- Previous message: Hugo Kornelis: "Re: Replace function problem"
- In reply to: Dr Tarheel: "Checking if a table exists, so that it may be dropped before recreating it"
- Next in thread: Tim S: "Re: Checking if a table exists, so that it may be dropped before recreating it"
- Reply: Tim S: "Re: Checking if a table exists, so that it may be dropped before recreating it"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|