从当前存储过程调用存储过程 [英] calling a stored procedure from the current stored procedure

查看:95
本文介绍了从当前存储过程调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过传递参数并将调用的存储过程中的值返回到调用存储过程,调用存储过程的步骤是什么? 。



最受欢迎的例子或网站参考。

解决方案

尝试:

  DECLARE   @ Return   INT  
EXEC @ Return = StoredProc2 @ Par1 @ Par2

如果需要非整数返回值,请添加OUTPUT参数。


检查这些 -

   -   调用存储过程 
EXEC SPName

- 使用参数调用存储过程
EXEC SPName @ param - ,@ param2,@ param3

< span class =code-comment> -
使用参数调用存储过程来捕获单个值
DECLARE @ ReturnValue VARCHAR 100 - 或您想要的数据类型
EXEC @ ReturnValue = SPName @ param - ,@ param2,@ param3

- 使用参数调用存储过程rs捕获多个值
DECALRE @ MyTableVar TABLE (ID INT ,名称 VARCHAR 50 ))
INSERT INTO @ MyTableVar
EXEC SPName @ param - < span class =code-comment>,@ param2,@ param3





希望,这有助于:)


What are the steps for calling a stored procedure by passing parameters and returning the values from the called stored procedure to the calling stored procedure.

An example or web site reference will be most welcomed.

解决方案

Try:

DECLARE @Return INT
EXEC @Return = StoredProc2 @Par1, @Par2

If you need a non-integer return value, add an OUTPUT parameter.


Check these-

--call your stored procedure
EXEC SPName 

--call stored proc with parameters
EXEC SPName  @param --,@param2,@param3

--call stored proc with parameters to capture single value 
DECLARE @ReturnValue VARCHAR(100) -- or the datatype you want
EXEC @ReturnValue = SPName  @param --,@param2,@param3

--call stored proc with parameters to capture multiple value 
DECALRE @MyTableVar TABLE(ID INT, Name VARCHAR(50))
INSERT INTO @MyTableVar
EXEC SPName  @param --,@param2,@param3



Hope, this helps :)


这篇关于从当前存储过程调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆