Avoid returning result set from stored procedure

Andrew Bezzub picture Andrew Bezzub · Jul 25, 2010 · Viewed 11.8k times · Source

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).

Answer

Florian Reischl picture Florian Reischl · Jul 25, 2010

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.