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

解决方案 »

  1.   

    if exists (select 1 from sysobjects where name = 'yourtable' and type = 'u')
       drop table yourtable
      

  2.   

    if exists (select name from sysobjects where name ='yourtable' and type = 'u')
       drop table yourtable
      

  3.   

    假设表名为t_001if exists (select * from dbo.sysobjects where id = object_id(N'[t_001]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [t_001]
    GO
      

  4.   

    在企业管理器中,你可以右键-->任意表-->生成sql脚本,生成sql脚本后你可以看到完整的生成表的sql语句