SSMs obtains the returned values and output values in the stored procedure.

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.