zoukankan      html  css  js  c++  java
  • 读取exec返回值

    读查询语句示例:
         Declare @count int

    1    set @strSql=N'select @a= count(*) from ['+ @tblName + '] where  1=1 '+   @strWhere
    2    exec sp_executesql  @strSql ,N'@a int output',@Count output
    3    select @Count
        
    要点:
     1.利用系统存储过程 sp_executesql
     2. 在要执行的Sql文中加入参数,如 "@a",在sp_executesql的参数  声 明中要指定参数的类型,参数的方向。
     3. sp_executesql的每个字符类型的参数都要是 n开头的数据类型,如是nvarchar 不能是      varchar,否则会报错 “过程需要类型为 'ntext/nchar/nvarchar' 的参数”.

    exec sp_executesql @rc,N'@a int output,@b int output',@cstucount output,@ccount output

      读存储过程示例:

    create procedure ProTest
    (
             @name varchar(10),
             @money int output
    )
    as
    begin
            if(@name='1')
                      set @money=1000
            else
                      set @money=2000
    end

    这个只是一个简单的示例,这个存储过程返回的是@money 这个参数的值,那么当我们在另外一个存储过程中调用此存储过程的时候如何获取这个参数呢,方法如下:


    declare @m int ---用来接收返回值的变量
    exec ProTest @name='1',@money=@m output --一定要注名是output

    就这么简单,我们就获得了返回值,然后就可以利用它了

  • 相关阅读:
    图像滤波
    直方图histeq
    直方图
    基于灰度变换的图像增强
    图像增强
    图像旋转和缩放
    图像点运算
    像素的连接与联通
    程序员进阶之算法练习(一)
    RxSwift 系列(二)
  • 原文地址:https://www.cnblogs.com/gxh973121/p/1430167.html
Copyright © 2011-2022 走看看