zoukankan      html  css  js  c++  java
  • 存储过程

     --创建存储过程 指定返回值
     CREATE PROCEDURE  testReturn
     AS
     return 145
     GO
     --执行存储过程
     DECLARE @RC int
     exec @RC=testReturn
     select @RC 
     
     --带输入参数的存储过程(存储过程语句中含有return)
     create procedure test_daican
      @username varchar(100),--用户名    
      @age int,--年龄
      @gender varchar(100)--性别
     as
     if(@username = '' or @username is null)--判断用户名是否为空
       return 1
     else
       begin
        insert into Student(username,age,gender) values(@username,@age,@gender)
        return 0
       end
       
     --调用
     
      declare @count int 
      exec @count = test_daican '',2,'123456' 
      select @count
      --
      declare @count int 
      exec @count = test_daican '赵子龙',2,'' 
      select @count
    
    
    --3.带输出参数的存储过程(存储过程中可以有return可以没有return)
    ---创建存储过程
     create procedure sp_output
      @output int output--表示输出参数
     as
      set @output = 121
      return 1
      
      --调用
      declare @out int
      exec sp_output @out output --输出
      select @out
      
      
  • 相关阅读:
    洛谷P2740 草地排水
    BZOJ 4326 运输计划
    BZOJ 1036 树的统计
    BZOJ 1003 物流运输
    BZOJ 1251 序列终结者
    HDU4864 Task(算竞进阶习题)
    洛谷P4281 紧急集合 / 聚会
    CH0802 占卜DIY
    node.js(二)各种模块
    node.js对象数据类型
  • 原文地址:https://www.cnblogs.com/yangxinghua/p/3673567.html
Copyright © 2011-2022 走看看