Set nocount
The returned results do not contain information about the number of rows affected by the transact-SQL statement.
SyntaxSet nocount {on | off}
NoteWhen set nocount is on, no count is returned (indicating the number
When set nocount is on, no count is returned (indicating the number of rows affected by the transact-SQL statement ). When set nocount is off, return the count.Even if set nocount is on
. Many steps may cause problems and affect the final result. At the same time, debugging is also troublesome. After SQL debug is embeddedProgramIt is very useful, and if the debug functions are all removed as mentioned by the author. And separated the database and application.
Someone in the comment wrote a simple test program and gave his test results. He thought it was still set
It is generally written in the storage State policy and the beginning and end. This way, you can reduce network data transmission without returning the affected number of rows.
Can be enhancedProgramThis is a bit more efficient.
Example:
Alter proc [DBO]. [usp_vo_getriskruleanditem]As/*Page: Change Risk Rule ConfigurationAction: Update change rule weight scoreCreated by: deitan. WangCreated Date: 06.27 11Test:Exec usp_vo_getriskruleanditem*/BeginSet no
procedure would be a times faster.There is no difference if you execute this procedure from the Management Studio with NOCOUNT OFF or onMY god!Seeing is believingBasically, they conclude that using NOCOUNT can reduce the transmission of the network. When we set NOCOUNT on, the stored procedure executes every
Every time we use the query analyzer to debug SQL statements, we usually see some information, reminding us how many rows are affected currently. What information is this? Is this information useful when we call it? Can I disable it?
The answer is the application of this information on our client.ProgramThe information is the done_in_proc information of each statement in the stored procedure.
We can use set
Label:In the stored procedure, the set NOCOUNT on is often used; Effect: Prevents the return of row count information in the result set that is displayed by T-SQL statements or by USP.When set Oncount on, the count is not returned, when
SET NOCOUNT
Causes the returned results to not contain information about the number of rows affected by Transact-SQL statements.
Grammar
SET NOCOUNT {on | OFF}
Comments
When SET NOCOUNT
I would like to ask: what does set nocount on mean? Why do many stored procedures cover the first line ?? Multi-region !!!Every time we use the query analyzer to debug SQL statements, we usually see some information, reminding us how many rows are affected currently. What information is this? Is this information useful when we call it? Can I disable it? The ans
I would like to ask: what does set nocount on mean? Why do many stored procedures cover the first line ?? Multi-region !!!Every time we use the query analyzer to debug SQL statements, we usually see some information, reminding us how many rows are affected currently. What information is this? Is this information useful when we call it? Can I disable it?
The ans
The returned results do not contain information about the number of rows affected by the transact-SQL statement.Syntax: Set nocount {on | off}The default value is off.
When set nocount is on, no count is returned (indicating the number of rows affected by the transact-
When set nocount is on, no count is returned (indicating the number of rows affected by the transact-SQL statement ). When set nocount is off, return the count. If some statements contained in the stored procedure do not return much actual data, this setting greatly reduces
SQL nocount statement
Default category09:19:57 read 205 comments 0 font size: large and small subscriptions
Every time we use the query analyzer to debug SQL statements, we usually see some information, reminding us how many rows are affected currently. What information is this? Is this information useful when we call it? Can I disable it? The answe
When set nocount is on, no count is returned (indicating the number of rows affected by the transact-SQL statement ).When set nocount is off, return count (default value: off ).
Even if set
When set nocount is on, no count is returned (indicating the number of rows affected by the transact-SQL statement ). When set nocount is off, return the count.
Even if set nocount is o
Set nocount on is often used in the stored procedure;
Purpose: prevents returned results from displaying row count information affected by T-SQL statements or USP.When set oncount on, no count is returned. When set nocount off,
Reference article: http://www.cnblogs.com/si812cn/archive/2008/06/11/1217113.htmlMy simple understanding is that:When executing SQL statementsSET OFF UPDATE SET = 1 WHERE = 1Here are the tips that appearReplace the SQLSET on UPDATE SET = 1 WHERE = 1The prompt that appears isIt is obvious that if set to on, the specif
Recently, I answered several similar questions on csdn.
Http://community.csdn.net/Expert/TopicView.asp? Id = 4131244
Http://community.csdn.net/Expert/TopicView.asp? Id = 4156955
Generally, I asked why an error occurred while not returning a dataset or assigning a record set to the table control.
There are several reasons for the problem
1. It is unclear about the return mechanism of ADO. Connection. Execute. All records returned using this method
When SET NOCOUNT is on, no count is returned (indicating the number of rows affected by the Transact-SQL statement). When SET NOCOUNT is OFF, the count is returned.
If some of the statements contained in a stored procedure do not return much of the actual data, this setting
Generally, @ rowcount and set nocount on are used in triggers. However, if you do not pay attention to the order between them, problems may occur. Today, I wrote a trigger that never worked, and I haven't found the cause for a long time. The Code is as follows:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Alter trigger [trg_houses_updated]
On [DBO]. [hou
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.