还有如果不存在某个存储过程就在庫中创立一个,有则不创建,谢谢

解决方案 »

  1.   

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CheckDetailMain]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
    drop procedure [dbo].[CheckDetailMain]
    GOCREATE PROCEDURE [dbo].[CheckDetailMain] @UseID Varchar(10)
    AS
    begin
    .....
    end
      

  2.   

    if not exists (select 1 from sysobjects a,syscolumns b where a.id = b.id and a.xtype = 'u' and a.name = tablename and b.name = columnname)
    begin
    --如果没有的话endif not exists (select 1 from sysobjects where xtype = 'p' and name = pname)
    begin
    --如果没有
    end