How to Suppress the Select Output of a Stored Procedure Called from Another Stored Procedure in SQL Server

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

I think I found a solution.

So what i can do now in my SQL script is something like this (sql-psuedo code):

create table #tmp(xmlReply varchar(2048))
while not_done
begin
select top 1 record from updateTable where processed = 0
insert into #tmp exec insertSomeData @param=record
end
drop table #tmp

Now if there was a even more efficient way to do this. Does SQL Server have something similar to /dev/null? A null table or something?

How do I suppress the results from a stored procedure from within a stored procedure?

You can try something like this:

/* Assume this table matches the output of your procedure */
DECLARE @tmpNewValue TABLE (newvalue int)
INSERT INTO @tmpNewValue
EXEC ProcedureB

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

Its not the NOCOUNT thats causing this, your stored procedures have a select each so each one is coming in its own result set. This could be avoided by changing your first stored procedure to use output parameters to pass the number 1 back rather than doing a select. The second stored procedure could then examine the output parameter to get the data it needs to run.

Try something like this

CREATE PROCEDURE Proc1
(
@RetVal INT OUTPUT
)
AS
SET NOCOUNT ON
SET @RetVal = 1


CREATE PROCEDURE Proc2
AS
SET NOCOUNT ON
DECLARE @RetVal int
EXEC [dbo].[Proc1]
@RetVal = @RetVal OUTPUT
SELECT @RetVal as N'@RetVal'

Suppress stored procedure result

No, you cannot suppress the SELECT result of sub-SPs without INSERT EXEC.

If you can change your sub-SPs, add an optional parameter at the end, @SlientExit bit = 0

IF @SlientExit = 1
RETURN

How do I disable query results when executing a stored procedure from a stored procedure?

you could insert the results into a temp table, then drop the temp table

create table #tmp (columns)

while
...
insert into #tmp exec @RC=dbo.NoisyProc
...
end
drop table #tmp

otherwise, can you modify the proc being called to accept a flag telling it not to output a result-set?



Related Topics



Leave a reply



Submit