gpt4 book ai didi

SQL Server 继续计算行数

转载 作者:行者123 更新时间:2023-12-04 14:22:46 24 4
gpt4 key购买 nike

我已经使用 SET NOCOUNT ON 禁用了行计数,但似乎 sqlserver 仍在计算行数。

USE Northwind
SET NOCOUNT ON;
SELECT * FROM Products p
SELECT @@ROWCOUNT AS 'RowCount';

查询返回 77 的行数,为什么?

最佳答案

设置无计数;

防止在执行存储过程时返回行数。它对@@rowcount 没有影响。

参见 http://msdn.microsoft.com/en-us/library/ms189837.aspx具体信息

The @@ROWCOUNT function is updated even when SET NOCOUNT is ON.

SET NOCOUNT ON prevents the sending of DONE_IN_PROC messages to the client for each statement in a stored procedure. For stored procedures that contain several statements that do not return much actual data, or for procedures that contain Transact-SQL loops, setting SET NOCOUNT to ON can provide a significant performance boost, because network traffic is greatly reduced."

关于SQL Server 继续计算行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12829055/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com