Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid returning result set from stored procedure

Assume I have some stored procedure (and I can't change it) which is returning a result set:

create procedure test_procedure
as
begin

    select 1

end

I know that I can insert result set into table, so it would be hidden to the calling code:

declare @t table(i int)

insert into @t
exec test_procedure

Are there any other ways to hide returning result set from the calling code?

Updated

It looks like I've been a bit confusing. I'm looking only for T-SQL answers (not .NET ones).

like image 545
Andrew Bezzub Avatar asked Jul 25 '10 15:07

Andrew Bezzub


People also ask

How do you suppress the Select output of a stored procedure called from another stored procedure in SQL Server?

To suppress MySQL stored procedure output, you can use variable. Let us first create a table. After calling the above stored procedure, we are not getting anything. Therefore, you need to use select statement to get the output.

Can stored procedure return value?

A stored procedure does not have a return value but can optionally take input, output, or input-output parameters. A stored procedure can return output through any output or input-output parameter.

How do you suppress in SQL?

The reporting of syntax errors in a batch can be suppressed using the /*IGNORE:*(BATCH)*/ comment. The syntax error suppression can be useful in scenarios where the analyzed SQL script contains some SQLCMD specific commands.


1 Answers

No, there is no other solution. However, you should refactor your procedure to do only what you need. If you need the output for other calls, try to split the procedure into two.

like image 93
Florian Reischl Avatar answered Sep 19 '22 20:09

Florian Reischl