if exists (select * from sysobjects where name = yourtablename and type = 'u')
   print '有'
else
   print '没有'愉快的登山者       ⊙
◢◣◢◣◢◣

解决方案 »

  1.   

    删除用drop table 命令
      

  2.   

    if exists(select 1 from sysobjects where id=object_id('你要测试是否存在的表'))
    begin
      print '表存在'
      drop table 你要测试是否存在的表' --删除表
    end
    else
      print '表不存在'
      

  3.   

    if exists (select * from sysobjects where name = yourtablename and type = 'u')
     begin    
       print '有'
       drop table yourtablename
     end
    else
       print '没有'
      

  4.   

    -- =============================================
    -- Create table basic template
    -- =============================================
    IF EXISTS(SELECT name 
      FROM   sysobjects 
      WHERE  name = N'<table_name, sysname, test_table>' 
      AND   type = 'U')
        DROP TABLE <table_name, sysname, test_table>
    GOCREATE TABLE <table_name, sysname, test_table> (
    <column_1, sysname, c1> <datatype_for_column_1, , int> NULL, 
    <column_2, sysname, c2> <datatype_for_column_2, , int> NOT NULL)
    GO
      

  5.   

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[room1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[room1]
    GOCREATE TABLE [dbo].[room1] (
    [fu] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
    [zi] [char] (10) COLLATE Chinese_PRC_CI_AS NULL 
    ) ON [PRIMARY]
    GO
      

  6.   

    if exists (select * from sysobjects where name = tablename and type = 'U')
       Drop table tablename
    else
      create table
      

  7.   

    select * from 表名
    存在就会显示
    drop table 表名
      

  8.   

    if object_id('表') is not null
    drop table 表