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
How to Find the Size of a Table in SQL
Getting the Number of Rows with a Group by Query
Difference Between Int Primary Key and Integer Primary Key SQLite
How to Use a Postgresql Triggers to Store Changes (SQL Statements and Row Changes)
Oracle - What Statements Need to Be Committed
SQL Server Invalid Column Name After Adding New Column
Efficiently Storing 7.300.000.000 Rows
New Line Issue When Copying Data from SQL Server 2012 to Excel
If Exists, Then Select Else Insert and Then Select
Declare Variable for a Query String
Unwrap Postgresql Array into Rows
Diff Between Top 1 1 and Select 1 in SQL Select Query
Postgresql - Best Way to Return an Array of Key-Value Pairs
Is Possible to Reuse Subqueries
Postgresql - Group by Clause or Be Used in an Aggregate Function