sql Get Stored Procedure Return Data Procedure Parsing

  • 2021-12-19 07:09:19
  • OfStack

This article mainly introduces the sql to obtain the stored process return data process analysis, the article through the example code introduction is very detailed, to everybody's study or work has 1 set of reference learning value, the need for friends can refer to the following

That is, after the storage is executed, the data executed by the stored procedure is obtained and used as other necessary 2 times.

In fact, it can be said that the call is similar in the code, and the specific operation is as follows:

Create a stored procedure:


use [ Library name ]
go
set ansi_null on
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE DBO.P_TEST
(
 @RBACK VARCHAR(20) OUT -- Here out Is to represent the need to return 
)
AS
BEGIN TRY
 SET @RBACK= (SELECT 2+2)
END TRY

The above script returns a result that 2 +2 equals 4

In how to call externally, or in other stored procedure scripts, as follows:


declare @RBACK VARCHAR(20)
EXEC  Library name .dbo.P_TEST @REBACK OUT
SELECT @REBACK

Execution is to return 4, so that you can use it flexibly and call

It is much more convenient in the later work


Related articles: