I've got a stored procedure (we'll call it A) that calls another stored procedure (we'll call this one B). B includes a SELECT that I do not want to send back to the caller of A.
Here is some really rough pseudocode, but it should get the idea across.
PROCEDURE A CURSOR CALL B -- I WANT TO SUPPRESS THE RESULTS FROM B END SELECT * END PROCEDURE B Do some interesting things SELECT * END
As you can see above, A calls B and B does some things that I want and returns results that I don't care about. Once A is done, it returns its own set of results.
How do I suppress the results from B in A? I'm using SQL Server 2005. I would prefer not to make changes to B because it is working and more complex than I want to mess with.
CROSS APPLY does not work for Stored Procedures, as they do not return datasets, just report outputs. Functions return anything, so that's why SQL can only use them when using CROSS APPLY.
Statement. To suppress a rule in a statement, the suppression mark must be suffixed with (STATEMENT) – IGNORE:RULENAME(STATEMENT). The suppression mark can appear anywhere in a comment inside the statement or just following the statement.
SET NOCOUNT ON prevents the sending of DONEINPROC messages to the client for each statement in a stored procedure.
The general solution for persisting a results set from a stored procedure is to store the results set(s) in one or more tables. You can use any of several different types of tables, including regular tables, local temp tables and global temp tables.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With