Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Optimization: Set Nocount On

From Wiki

Jump to: navigation, search

When you have a lot of updates and inserts or deletes in a stored procedure it is good to set nocount to on. SQL server can become really chatty when this setting is off; this will waste bandwith and CPU power. If a proc is called 30 times a second and you do 3 DML operations then that will result in 90 n row(s) affected) messages

set nocount on should be the first statement in the proc after the parameters and the AS. Example:

  1. CREATE PROC Employee
  2. @Param1 INT
  3. AS
  6. ...rest OF PROC

Contributed by: --SQLDenis 15:25, 31 May 2008 (GMT)

Part of SQL Server Programming Hacks - 100+ List

Section Query Optimization

283 Rating: 2.5/5 (120 votes cast)