if exists (select * from dbo.sysobjects where id = object_id(N'[mytbl]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [mytbl]
GOcreate table [mytbl] (
....
)GO

解决方案 »

  1.   

    if not exists(select 1 from sysobjects where name='mytbl' and xtype='U')
      create table mytbl(....)
      

  2.   

    枚举:
    select name from dbo.sysobjects where OBJECTPROPERTY(id, N'IsUserTable') = 1
      

  3.   

    --枚举一个数据库中所有表的名称select name from sysobjects where xtype='U'--枚举一个数据库中所有用户表的名称select name from sysobjects where xtype='U' and status>=0
      

  4.   

    if objectproperty(object_id(@table_name),'isusertable') is not null
    存在
    else
    不存在
      

  5.   

    如果是在oracle下,你可以查询这样几个表:
    cat
    tab
    user_tables
      

  6.   

    表名:t_1
    1.
       if object_id('t_1') is not null
       drop table t_1
    2.
       if exists(select * from dbo.sysobjects where name='t_1' and xtype='U')
       drop table t_1