本文介绍了SQL Server 2005 SP中的SP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有关于存储过程的查询

作为

我正在编写一个正在运行另一个sp的存储过程,所以我的查询是

Hi ,

I have query on Stored proc

As

I am writing a stored proc in which another sp is running , so my query is

Create Proc  Sp_firstSP
AS
Begin
SET NOCOUNT ON

firstparameter1 varchar(20 ) ,
secondparameter int ,
thirdparameter varchar(20)

BEGIN
IF ( status = 1 )
  execute secondproc @inparam1 @inparam2
                     @outParam1   @outParam2
  update tablename1 set column1 =  @outParam1    , column2 = @outParam2
             where condition
END


-现在我的查询是如何在我的firtsp中获取outparam,以便它将成为firstsp的输入

如何编写存储的proc以便在当前应用程序中使用?


-- now here my query is how can i get the outparam in my firtsp so that it will become the input of the firstsp

How can i write the stored proc for use in my current application

推荐答案

CREATE PROCEDURE sp_first_test
@firstParam INT,@secondParam INT,
@firstOutParam INT OUTPUT,@secondOutParam INT OUTPUT
AS
BEGIN

   SELECT @firstOutParam = @firstParam + @secondParam

   SELECT @secondOutParam =@firstParam - @secondParam
END

GO

CREATE Procedure sp_second_test
@firstParam INT,@secondParam INT
AS
BEGIN
DECLARE @OutParam1 INT
DECLARE @OutParam2 INT

EXEC sp_first_test @firstParam,@secondParam,@OutParam1 OUTPUT,@OutParam2 OUTPUT

SELECT @OutParam1,@OutParam2
-- Here you can put your update query ...

END

GO

exec sp_second_test 5,2


这篇关于SQL Server 2005 SP中的SP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 08:02