避免从存储过程返回结果集
假设我有一些返回结果集的存储过程(并且我无法更改它):
create procedure test_procedure
as
begin
select 1
end
我知道我可以将结果集插入表中,因此它将对调用代码隐藏:
declare @t table(i int)
insert into @t
exec test_procedure
是否有其他方法可以隐藏从调用代码返回结果集?
已更新
看起来我有点困惑。我只寻找 T-SQL 答案(不是 .NET 答案)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,没有其他解决方案。但是,您应该重构您的过程以仅执行您需要的操作。如果您需要其他调用的输出,请尝试将过程分成两个。
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.
使用可选的输出参数。
或使用下面的情况
编写任何满足并返回指定值的条件。
使用该参数作为可选参数,这样您的过程中就不会发生其他更改。
Use optional Output Parameter.
or use below case
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.
您是否愿意尝试通过输出参数返回数据,并返回状态代码作为过程的返回值?
您无法轻松地通过该输出参数返回完整的结果集,但您可以以您选择的格式返回一些分隔数据。
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.