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

后端 未结 10 1983
误落风尘
误落风尘 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:42

    The answer you're looking for is found in a similar SO question by Josh Burke:

    -- Assume this table matches the output of your procedure
    DECLARE @tmpNewValue TABLE ([Id] int, [Name] varchar(50))
    
    INSERT INTO @tmpNewValue 
      EXEC ProcedureB
    
    SELECT * FROM @tmpNewValue
    
    0 讨论(0)
  • 2020-12-15 15:42

    ever tried SET NOCOUNT ON; as an option?

    0 讨论(0)
  • 2020-12-15 15:44

    I have recently come across with a similar issue while writing a migration script and since the issue was resolved in a different way, I want to record it. I have nearly killed my SSMS Client by running a simple while loop for 3000 times and calling a procedure.

    DECLARE @counter INT
    SET @counter = 10
    WHILE @counter > 0 
    BEGIN 
        -- call a procedure which returns some resultset
        SELECT  @counter-- (simulating the effect of stored proc returning some resultset)
        SET @counter = @counter - 1
    END
    

    The script result was executed using SSMS and default option on query window is set to show “Results to Grid”[Ctrl+d shortcut].

    Easy Solution: Try setting the results to file to avoid the grid to be built and painted on the SSMS client. [CTRL+SHIFT+F keyboard shortcut to set the query results to file].

    This issue is related to : stackoverflow query

    0 讨论(0)
  • 2020-12-15 15:47

    You could create a SQL CLR stored procedure that execs this. Should be pretty easy.

    0 讨论(0)
提交回复
热议问题