Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 it is a good practice then to put SET NOCOUNT ON

Author  Topic 

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-06-14 : 12:43:54
it is a good practice then to put SET NOCOUNT ON all my stored procedures ?

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-06-14 : 12:44:56
I see a good deal of SPs in some of my clients that do not have this, but I am certainly willing to do it, if this is the right approach
Go to Top of Page

rudesyle
Posting Yak Master

110 Posts

Posted - 2007-06-14 : 12:57:54
Yes. it suppresses sql server messages (like 1 row affected) that you generally won't need.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-14 : 13:02:44
Yes it is a good practice. Depending on how complex the procs are..basically almost every T-SQL generates some kind of message which is passed on to the caller. So bigger procs have lot more info that will be sent back to the application unnecessarily choking the bandwidth.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-06-14 : 14:15:06
We put this as the first statement in every SProc

SET NOCOUNT ON
SET XACT_ABORT ON
SET ARITHABORT ON

Kristen
Go to Top of Page

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-06-14 : 14:18:30
what those other two do ?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-06-14 : 14:23:54
Have a look in the SQL Documentation!
Go to Top of Page

rudesyle
Posting Yak Master

110 Posts

Posted - 2007-06-14 : 14:23:56
quote:
Originally posted by Kristen

We put this as the first statement in every SProc

SET NOCOUNT ON
SET XACT_ABORT ON
SET ARITHABORT ON

Kristen



You would think by now that the Sql Server team would make this property you could toggle in Management Studio.....
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-06-14 : 14:24:56
Is "Management Studio" some new-fangled gizmo?
Go to Top of Page

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-06-14 : 14:51:50
I checked the documentation, very good statements indeed to have
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-06-14 : 16:10:16
Excellent! Just watch out for XACT_ABORT, if you do manage to have very VERY tight error handling in your SProcs you may not want this as it will cause SQL Server to just abort your Sproc.

Kristen
Go to Top of Page

dbwilson4
Yak Posting Veteran

50 Posts

Posted - 2007-06-14 : 17:11:01
I really don't think this is necessary.

Bandwidth? Nowdays, both the SQL and APP servers are located in the same colocation and therefore network congestion is USUALLY not an issue. Yes, it might send more info back to the app server but with quad-core cpus out these days and faster SCSI disks, do we really need to "micro" optimize with things like that????

However, it varies with each situation but for most situtations (especially where the db and app server are close to each other), you don't need to microoptimize like this.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-06-15 : 04:22:28
I reckon your answer was intended to be against a different thread which I read only a short while ago ... but I can't find it now!

Or did I get that wrong?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-16 : 02:47:58
May this be helpful?
http://www.sqlservercentral.com/columnists/dpoole/2751.asp

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -