May 29, 2003 at 9:55 am
How do I Check initally if a Object exists. The reason Being I need to Drop an exsisting table before i Recreate the Table With a Select Into Query. If The Table Does not exist i want the Select into Statement to Execute but if the Table exsists i want to drop the Table before i recreate the table with the Select into Statement. I Hope this question Makes Sense.
Anthony Malone
Anthony Malone
May 29, 2003 at 9:59 am
if exists (select 1
from sysobjects
where id = object_id('yourtable')
and type = 'U')
select into .........
else
drop table yourtable
Luani
Luani
May 29, 2003 at 10:33 am
That is kinda backwards. I always use
IF COALESCE(objectproperty(object_id('TEST_TABLE'),'IsTable'),0) = 1
begin
drop table TEST_TABLE
end
Much faster and simpler than hitting sysobjects
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply