CREATE PROCEDURE p_pp
if exists (select * from sysobjects where id = object_id(N'[dbo].[t_bxd]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 
drop table [dbo].[t_bxd]
我用这个后 出现IF语句错误

解决方案 »

  1.   

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

  2.   

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

  3.   

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

  4.   

    IF EXISTS(SELECT * FROM SYSOBJECTS WHERE NAME='TB')
    DROP TABLE TB
      

  5.   

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