Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2003, 04:11 AM
Authorized User
 
Join Date: Sep 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to balakumar1000
Default Set nocount on

We are using a statement "set nocount on" in Stored Procedures to avoid the display texts "1 row updated" , "2 rows deleted" something like that. (Programmers say that they make use of this is to avoid unnecessary network traffic)
Will these messages "1 row updated" , "2 rows deleted" really come to client. If so then how can we get those messeges..Is there any method or property in ADO to fetch these messeages.

Balakumar V.

__________________
Balakumar Vijayan
Sr. S/W Engr.
Trivandrum
 
Old October 13th, 2003, 09:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you do not use "set nocount on" in a stored procedure, the "nn rows ..." message is returned to the provider as a resultset. The provider (i.e. ADO) then inspects and parses this resultset and returns the value in it via the "recordsaffected" parameter on the execute methods of the command and/or connection objects.

Doing this requires some overhead on both the client and the server, as well as some network traffic to transmit the resultset.

If you need the value in your client application, don't use set nocount, and provide a variable that the command or connection execute method can deposit the value into.

If you never care about the "recordsaffected" value, it is wise (IMO) to use 'set nocount on' to avoid the needless extra overhead.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath: set operation with a disjoint node set rich_unger XSLT 7 May 6th, 2008 09:24 AM
how i set charcter set to a connection yoord BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 April 23rd, 2005 07:47 AM
How to set DOM character set sonicDace XML 0 May 27th, 2004 08:52 AM
Effect of set nocount on return status puneetmittal1974 SQL Server 2000 5 May 24th, 2004 04:28 AM
Set Nocount On Colonel Angus SQL Server 2000 2 April 21st, 2004 10:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.