How To Declare Input-Output Parameters In SQL Server Stored Procedure/Function?

后端 未结 2 1361
难免孤独
难免孤独 2020-12-20 12:41

In Oracle,

We can declare an input-output parameters (not just input or output) like the following:

Create Or Replace Procedure USE         


        
2条回答
  •  一生所求
    2020-12-20 13:22

    If you declare a parameter as OUTPUT, it acts as Both Input and OUTPUT

    CREATE PROCEDURE SimpleInOutProcedure 
    (
        @p_InputInt  INT,
        @p_OutputInt INT OUTPUT
    )
    AS
    BEGIN
        SELECT 
           @p_OutputInt = @p_OutputInt
    END
    GO
    
    DECLARE @p_OutputInt int = 4
    EXEC SimpleInOutProcedure @p_InputInt = 1, @p_OutputInt = @p_OutputInt OUTPUT
    SELECT @p_OutputInt
    

提交回复
热议问题