Set NOCount On

Stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results.

停止返回指示一个T-SQL语句影响的行数的信息作为返回结果的一部分。

Syntax 语法

SET NOCOUNT { ON | OFF }

Remarks

备注: When SET NOCOUNT is ON, the count (indicating the number of rows affected by a Transact-SQL statement) is not returned. When SET NOCOUNT is OFF, the count is returned.

当 Set NoCount设为On时,显示T-SQL语句影响的行数的信息不被返回。当Set NoCount设为Off时,行数将被返回。

The @@ROWCOUNT function is updated even when SET NOCOUNT is ON. 当Set NoCount设为On时,@@RowCount函数也会更新。

SET NOCOUNT ON eliminates the sending of DONE_IN_PROC messages to the client for each statement in a stored procedure. When using the utilities provided with Microsoft® SQL Server™ to execute queries, the results prevent "nn rows affected" from being displayed at the end Transact-SQL statements such as SELECT, INSERT, UPDATE, and DELETE.

Set NoCount On去除了在一个存储过程中每个语句的Done_In_Proc消息传递给客户的过程。当使用由Microsoft® SQL Server™提供的实用工具执行查询时,执行结果防止了“n 行 受到了影响”在一个如Select,Insert,Update,Delete的T-SQL语句结束时显示。

For stored procedures that contain several statements that do not return much actual data, this can provide a significant performance boost because network traffic is greatly reduced.

对于包含了很多不返回实际数据的语句的存储过程,使用Set NoCount on可以很大的提高性能,因为网络流量可以大幅减少。

The setting of SET NOCOUNT is set at execute or run time and not at parse time.

Set OnCount是在执行时设置而不是在分析阶段。

结论:当没有必要返回给客户端“n 行受到影响”消息时,应该在存储过程的开始设置 SET NOCOUNT ON,在存储过程结束时设置SET NOCOUNT OFF.

如果未关闭,则下次hibernate 等持久化时会报错!

(纯属个人总结,呵呵,自己学习)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值