zoukankan      html  css  js  c++  java
  • 数据库sqlserver添加存储过程,判断是否存在

    1、创建存储过程

    create proc 存储过程名称

    @参数(可添加多个,格式:@参数,也可不添加参数)

    as
    begin
    select * from Base_Apply where F_Id=@参数(添加参数写法)/  select * from Base_Apply where F_Id=具体值(不添加参数写法)
    end;

    2、判断存储过程是否存在

    if exists (select * from dbo.sysobjects where id = object_id(N'dbo.存储过程名称') and OBJECTPROPERTY(id, N'IsProcedure') = 1) 
    print '存在'
    else
    print '不存在'

    3、判断要创建的存储过程名是否存在    
      if   exists   (select   *   from   dbo.sysobjects   where   id   =   object_id(N’ [dbo].[存储过程名]’)   and   OBJECTPROPERTY(id,   N’IsProcedure’)   =   1)    
      --   删除存储过程    
      drop   procedure   [dbo].[存储过程名]    
      GO  

    4 、判断要创建的表名是否存在    
      if   exists   (select   *   from   dbo.sysobjects   where   id   =   object_id(N’ [dbo].[表名]’)   and   OBJECTPROPERTY(id,   N’IsUserTable’)   =   1)    
      --   删除表    
      drop   table   [dbo].[表名]    
      GO   

  • 相关阅读:
    你自己不优秀,就算认识再多优秀人又有何用
    史玉柱和他老同学的一段故事
    哪有雪中送碳,都是锦上添花
    围城之困
    心已死,梦前行
    一位销售高手逼单经历!
    Python--函数return多个值
    Python--内置函数
    Python--小程序
    Python--递归
  • 原文地址:https://www.cnblogs.com/jsfh/p/12784915.html
Copyright © 2011-2022 走看看