table already exists ??? 
Author Message
 table already exists ???

What is the store procedure or command
to check if a table or view already exists?

Thanks



Mon, 17 Sep 2001 03:00:00 GMT
 table already exists ???

What version?
In 6.5, you have to look in the sysobjects table to see if your object
already exists.
In 7.0, you can use the OBJECTPROPERTY function with the property "ISTABLE"
or "ISVIEW".

HTH

--
Kalen Delaney
MCSE, SQL Server MCT, MVP
(Please do not send email.
  Post all followups to the newsgroups.)

Quote:

>What is the store procedure or command
>to check if a table or view already exists?

>Thanks



Mon, 17 Sep 2001 03:00:00 GMT
 table already exists ???

if exists (select * from sysobjects where id = object_id('TABLENAME') and
sysstat & 0xf = 3)

This works for a table, for a view, I think that the 0xf number is 7, but
you can check that by doing a SELECT * from sysobjects.

Hope it works for you,

Scott



Quote:

> What is the store procedure or command
> to check if a table or view already exists?

> Thanks



Mon, 17 Sep 2001 03:00:00 GMT
 table already exists ???
Thanks. It works as well as the previous one.

For view, it seems the 0xf number is 2.

Quote:

> if exists (select * from sysobjects where id = object_id('TABLENAME') and
> sysstat & 0xf = 3)

> This works for a table, for a view, I think that the 0xf number is 7, but
> you can check that by doing a SELECT * from sysobjects.

> Hope it works for you,

> Scott



> > What is the store procedure or command
> > to check if a table or view already exists?

> > Thanks



Tue, 18 Sep 2001 03:00:00 GMT
 table already exists ???
Yea, you are right each of the groups(table, views, stored procs) all have
different 0xf numbers.  I always get them confused.

Scott



Quote:
> Thanks. It works as well as the previous one.

> For view, it seems the 0xf number is 2.


> > if exists (select * from sysobjects where id = object_id('TABLENAME')
and
> > sysstat & 0xf = 3)

> > This works for a table, for a view, I think that the 0xf number is 7,
but
> > you can check that by doing a SELECT * from sysobjects.

> > Hope it works for you,

> > Scott



> > > What is the store procedure or command
> > > to check if a table or view already exists?

> > > Thanks



Mon, 01 Oct 2001 03:00:00 GMT
 table already exists ???
You must to use the type of object example :  type = "U"  for user table.

your  code must look like this
 if exists (select * from sysobjects where id = object_id('TABLENAME')
and
type = "U")

Kendall Cardona

Quote:

>Yea, you are right each of the groups(table, views, stored procs) all have
>different 0xf numbers.  I always get them confused.

>Scott



>> Thanks. It works as well as the previous one.

>> For view, it seems the 0xf number is 2.


>> > if exists (select * from sysobjects where id = object_id('TABLENAME')
>and
>> > sysstat & 0xf = 3)

>> > This works for a table, for a view, I think that the 0xf number is 7,
>but
>> > you can check that by doing a SELECT * from sysobjects.

>> > Hope it works for you,

>> > Scott



>> > > What is the store procedure or command
>> > > to check if a table or view already exists?

>> > > Thanks



Tue, 02 Oct 2001 03:00:00 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. ExecuteSQL Err - Table already exists

2. How to check if an tempory table already exists

3. How to check if a table already exists

4. check if table already exists??

5. How to find out if a table already exists with PL/SQL

6. vb: check if table already exists??

7. Temporary Table already exists

8. table already exists error

9. Partioning Tables in 8.1.5 where tables already exist.

10. How do I find out if a table already exists?

11. How do I check if a table already exists?

12. add new table unless already exists


 
Powered by phpBB® Forum Software