Preface
We often call other stored procedures in the stored procedure. How can we obtain the returnvalue and outputvalue of another stored procedure?
Create a table (folder) as follows:
Column name |
Type |
Remarks |
Folderid |
Int |
Automatic increase or decrease of Folder Id primary key |
Foldername |
Nvarchar (50) |
Folder name |
Parentfolderid |
Int |
Parent Folder Id |
Groupno |
Nvarchar (12) |
UnitCode |
Userid |
Int |
User ID |
Createtime |
Datetime |
Folder creation time |
The stored procedure is as follows:
Alter procedure DBO . Base_createfolder ( @ Foldername Nvarchar ( 50 ), @ Parentfolderid Int = Null , @ Groupno Nvarchar ( 12 ), @ Userid Int , @ Folderid Int = Null Output ) As /* Set nocount on */ Insert Wfmt_folder ( Foldername , Parentfolderid , Groupno , Userid , Createtime ) Values ( @ Foldername , @ Parentfolderid , @ Groupno , @ Userid , Getdate ()) Select @ Folderid = @ Identity Return 1
Execute the stored procedure in SSMs:
Declare@ OutputvalueIntdeclare@ ReturnvalueIntexec@ Returnvalue=Base_createfolder @ Foldername='123',@ Groupno='1',@ Userid=1,@ Folderid=@ OutputvalueOutputselectOutvalue=@ Outputvalue,Returnvalue=@ Returnvalue
Result: