SQL Server output parameter issue

后端 未结 8 1757
南旧
南旧 2020-12-24 11:42

I am using SQL Server 2008 Enterprise. I am learning OUTPUT parameter of SQL Server stored procedure. For example, stored procedure sp_add_jobschedule has an OUTPUT paramete

8条回答
  •  孤独总比滥情好
    2020-12-24 12:23

    The question is - why do you want to disallow to provide input? This makes no sense whatsoever. Consider this simple example:

    CREATE PROCEDURE test (@param AS INT OUTPUT) AS
    BEGIN
      SET @param = 100
    END
    GO
    
    DECLARE @i INT
    SET @i = 0
    
    EXECUTE test @i OUTPUT
    PRINT @i
    
    DROP PROCEDURE test
    

    This prints

    100
    

    See - how are you supposed to get a value out if you do not put a variable in first?

提交回复
热议问题