是否可以执行具有输出参数的 T-SQL 存储过程,同时忽略 SELECT 语句?
我正在从另一个存储过程调用一个存储过程,并且我调用的过程有一个输出参数。然后我将输出值传输到局部变量中。这一切都很好,但问题是该过程中还有一个 select
语句,因此当我 exec
时,该过程的结果将在最终结果集。
有没有一种方法可以简单地获取输出参数的值,而忽略其他所有内容?
I am calling one stored procedure from another, and the procedure I am calling has an output parameter. I am then piping the output value into a local variable. That's all well and good, but the problem is that this procedure also has a select
statement in it, so when I exec
, the results of the procedure are being returned in the final results set.
Is there a way to simply get the value of the output parameter, and ignore everything else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然从技术上讲是可以的,但你不应该这样做。引擎消耗资源来生成您忽略的结果集。你们也可能会产生不必要的争用。如果您不需要结果集,则需要另一个过程来仅产生您想要的输出。
While technically yes, you shouldn't do it. The engine consumes resources to produce the result set you ignore. You may also produce unnecessary contention. If you don't need the result set, you need another procedure that should only produce the output you desire.
我确信有一些技巧可以做到这一点 - 但我想到的明显解决方案是:
...根据 Remus 的回答,这是对 CPU、I/O 等的浪费。
如果你可以添加一个额外的存储过程的参数允许抑制结果集,那就太棒了。
I'm sure there are some tricks for doing this - but the obvious solution that springs to mind is:
...as per Remus' response, this is a waste of CPU, I/O, etc.
If you can add an additional parameter to your stored procedure that allows the suppression of the resultset, that'd be grand.