避免从存储过程返回结果集 [英] Avoid returning result set from stored procedure

查看:67
本文介绍了避免从存储过程返回结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一些返回结果集的存储过程(并且我无法更改它):

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?

更新

我好像有点糊涂了.我只在寻找 T-SQL 答案(不是 .NET 答案).

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

推荐答案

不,没有其他解决方案.但是,您应该重构您的程序以仅执行您需要的操作.如果您需要其他调用的输出,请尝试将过程拆分为两个.

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.

这篇关于避免从存储过程返回结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆