views:

148

answers:

3

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

+2  A: 

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.

Greets Flo

Florian Reischl
A: 

Would you rather try to return your data through an output parameter, and return a status code as the procedure's return value?

You couldn't easily return a full resultset through that output parameter, but you could return some delimited data in a format of your choosing.

Allbite
As I said I can't change stored procedure which returns result set.
Andrew Bezzub
Could you wrap it in another procedure you have control over? Your wrapper could throw away the resultset.
Allbite
A: 

Use optional Output Parameter.

or use below case

Create procedure Check @c int as begin if @c = 1 select 1 else print 1 end

write any condition that will satisfy and that returns you specified values. use that parameter as optional so no other change in your procedure will come.

KuldipMCA