Is quot;SET NOCOUNT OFFquot; necessary in a stored procedure?(是“SET NOCOUNT OFF吗?需要在存储过程中吗?)
问题描述
我有很多set nocount on
的程序.
是否需要在存储过程结束时将其关闭?
Is it necessary to turn it off at the end of stored procedure?
例如:
create procedure DummyProc
as
begin
set nocount on
...
set nocount off
end
推荐答案
set nocount on
将禁用 X 行受影响.
消息 SQL 返回.在某些情况下,由于客户端执行存储过程的不良影响,此消息被抑制.
set nocount on
will disable the X rows affected.
message SQL returns. This message is suppressed, in some cases, due to undesired effects with the client executing the stored proc.
set nocount off
将取消此抑制.但是,set nocount on
是一个范围设置,默认情况下,无论如何离开范围时都会关闭.
set nocount off
will undo this suppression. However, set nocount on
is a scope setting, and by default, will be turned off when leaving the scope anyway.
现在,是否需要set nocount off
?不,因为执行的任何新命令都将在不同的范围内,并且默认情况下 set nocount off
始终有效.但正如上面评论中所述,这被认为是一种很好的做法,只是明确表明该设置将在 proc 执行完成后恢复正常.
Now, is set nocount off
necessary? No, as any new commands executed will be in a different scope, and by default set nocount off
is always in effect. But as stated above in comments, it's considered a good practice, just to explicitly indicate that this setting will return to normal when the proc is finished executing.
这篇关于是“SET NOCOUNT OFF"吗?需要在存储过程中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是“SET NOCOUNT OFF"吗?需要在存储过程中吗?


基础教程推荐
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 在多列上分布任意行 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01