How to Suppress the SELECT Output of a Stored Procedure called from another Stored Procedure in SQL Server?

后端 未结 10 2048
误落风尘
误落风尘 2020-12-15 14:50

I\'m not talking about doing a \"SET NOCOUNT OFF\". But I have a stored procedure which I use to insert some data into some tables. This procedure creates a xml response s

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 15:27

    Man, this is seriously a case of a computer doing what you told it to do instead of what you wanted it to do.

    If you don't want it to return results, then don't ask it to return results. Refactor that stored procedure into two:

    CREATE PROCEDURE [dbo].[insertSomeData] (@myParam int) AS
    BEGIN
    DECLARE @reply varchar(2048)
    
    --... Do a bunch of inserts/updates...
    
    EXEC SelectOutput
    END
    GO
    
    CREATE PROCEDURE SelectOutput AS
    BEGIN
    SET @reply = ''
    SELECT @reply
    END
    

提交回复
热议问题