MS SQL: Suppress return value of stored procedure called in stored procedure

后端 未结 3 535
一个人的身影
一个人的身影 2021-01-11 13:34

I think I have the same problem as kcrumley describes in the question \"Problem calling stored procedure from another stored procedure via classic ASP\". However his questio

3条回答
  •  温柔的废话
    2021-01-11 14:06

    As Matt points out in his comment, neither solution really 'swallow' the first resultset. I don't know why you'd want this but you can 'swallow' the result of the first exec by using a table variable. It must match the exact amount and type of the result set's columns. Like so:

    CREATE PROCEDURE return_1 AS 
        SET NOCOUNT ON;
        SELECT 1
    GO
    CREATE PROCEDURE call_return_1_and_return_2 AS 
        SET NOCOUNT ON;
        DECLARE @Result TABLE (res int)
        insert into @Result EXEC return_1
        SELECT 2
    GO
    

提交回复
热议问题