if exists(select 1 from dbo.sysobjects where name='你的表' and type='U')  
  drop table 你的表

解决方案 »

  1.   

    if exists(select 1 from dbo.sysobjects where name='你的表' and type='U')
      drop table 你的表
      

  2.   


    if exists(select * from sysobjects where id=object_id('a') and xtype='a')
    drop table a
      

  3.   

    上面错误:
    if exists(select * from sysobjects where id=object_id('a') and xtype='u')
    drop table a
      

  4.   

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

  5.   

    新的方法:
    if exists(select table_name from information_schema.tables
    where table_name='employees')
    drop table employees
      

  6.   

    if exists (select 1 from sysobjects where xtype='u' and status > 1 and name = 'a')
    drop table a
      

  7.   

    哦,谢谢大家
    为什么sqlserver得这么麻烦哪,呵呵
      

  8.   

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