0

Possible Duplicate:
SET NOCOUNT ON usage

Why do we use the below statement in Triggers and stored procedures?

SET NOCOUNT ON

Could any one explain me please? I have gone through the similar question posted before. But as I am new learning SQL, I am unable to understand their discussion.

Community
  • 1
  • 1
Shine
  • 1,413
  • 3
  • 15
  • 18

1 Answers1

0

When SET NOCOUNT is ON, the count (indicating the number of rows affected by a Transact-SQL statement) is not returned. When SET NOCOUNT is OFF, the count is returned.

So if you do an UPDATE query (for example) the query will not return the affected rows.

for more information check out => http://msdn.microsoft.com/en-us/library/aa259204(v=sql.80).aspx

dknaack
  • 60,192
  • 27
  • 155
  • 202
  • The article you referenced simply uses misleading terminology, and frankly is wrong. `SET NOCOUNT ON` will cause it not to *display a message indicating the number of rows returned*. It will *not* affect the number of rows returned. See http://blog.sqlauthority.com/2011/12/02/sql-server-effect-of-set-no-count-on-rowcount/ – Jay Sullivan Mar 11 '14 at 20:08