[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

set nocount scope

Posted on 2004-10-24
2
Medium Priority
?
1,083 Views
Last Modified: 2011-09-20
I'm having trouble understanding the scope of a command like SET NOCOUNT ON. I know I want to use this in stored procedures, but do I put this command in the sp's definition or outside the CREATE PROCEDURE command? Does running the command only last for one transaction?
0
Comment
Question by:elmoredaniel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
Colosseo earned 1200 total points
ID: 12395377
Hi

yes you are right you put it inside the definition, so for example you might have

CREATE PROCEDURE get_Table1_p

AS

SET NOCOUNT ON

SELECT * FROM Table1

As for whether or not it only lasts for one transaction I am pretty sure that it is specific to the sp that it is included in.

I know that I use it in every sp I write as it does helps to reduce network traffic by not returning the number of rows affected line when it is not needed.

HTH

Scott
0
 
LVL 6

Assisted Solution

by:curtis591
curtis591 earned 800 total points
ID: 12395394
It is a connection level setting, so it lasts while you have that connection to the server.  You could put it in either place I guess.  There is a connection default that you can set all connections that connect to your sql server.  Right click on your server in Enterprise Manager click properties and it is in there.  (It might be set on the database if is not in there but I am pretty sure it is on the server)  If you switch it for the connection I am not to sure what else it effects.  We have always just set it in the procedures.
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question