SETNOCOUNT的用法

来源:互联网 发布:淘宝上买组装机怎么样 编辑:程序博客网 时间:2024/05/16 05:03
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
SETNOCOUNT
使返回的结果中不包含有关受Transact-SQL语句影响的行数的信息。
语法
SETNOCOUNT{ON|OFF}
注释
当SETNOCOUNT为ON时,不返回计数(表示受Transact-SQL语句影响的行数)。当SETNOCOUNT为OFF时,返回计数。

即使当SETNOCOUNT为ON时,也更新@@ROWCOUNT函数。

当SETNOCOUNT为ON时,将不给客户端发送存储过程中的每个语句的DONE_IN_PROC信息。当使用Microsoft®™提供的实用工具执行查询时,在Transact-SQL语句(如SELECT、INSERT、UPDATE和DELETE)结束时将不会在查询结果中显示"nnrowsaffected"。

如果存储过程中包含的一些语句并不返回许多实际的数据,则该设置由于大量减少了网络流量,因此可显着提高性能。

SETNOCOUNT设置是在执行或运行时设置,而不是在分析时设置。
权限
SETNOCOUNT权限默认授予所有用户。
示例
下例在osql实用工具或SQLServer查询分析器中执行时,可防止显示有关受影响的行数的信息。

USEpubsGO--Displaythecountmessage.SELECTau_lnameFROMauthorsGOUSEpubsGO--SETNOCOUNTtoONandnolongerdisplaythecountmessage.SETNOCOUNTONGOSELECTau_lnameFROMauthorsGO--ResetSETNOCOUNTtoOFF.SETNOCOUNTOFFGO







注意:





当SETNOCOUNT为ON时,不返回计数(表示受Transact-SQL语句影响的行数)。当SETNOCOUNT为OFF时,返回计数。

即使当SETNOCOUNT为ON时,也更新@@ROWCOUNT函数。

当SETNOCOUNT为ON时,将不给客户端发送存储过程中的每个语句的DONE_IN_PROC信息。当使用Microsoft&reg;SQLServer&#8482;提供的实用工具执行查询时,在Transact-SQL语句(如SELECT、INSERT、UPDATE和DELETE)结束时将不会在查询结果中显示"nnrowsaffected"。

如果存储过程中包含的一些语句并不返回许多实际的数据,则该设置由于大量减少了网络流量,因此可显着提高性能。

SETNOCOUNT设置是在执行或运行时设置,而不是在分析时设置。








查询分析器中,不显示消息,比如”影响多少行“之类的信息





<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击