What is the use of "SET NOCOUNT ON;" in SQL Server?

 Posted by SheoNarayan on 7/6/2010 | Category: Sql Server Interview questions | Views: 51501
Answer:

This statement is used to stop the message that shows the count of the number of rows affected by the SQL statement written in the stored procedure or directly SQL Statement. You can view this message in the Management Studio in the Message tab of the result pan.

When it is ON - the number of affected rows will not be returned
When it is OFF - the number of affected rows will be returned

More on this ....

@@ROWCOUNT is used to get the number of rows affected. Note that either the SET NONCOUNT is ON or OFF, @@ROWCOUNT is always updated with the number of rows affected.

For more detailed information on this, visit http://msdn.microsoft.com/en-us/library/ms189837.aspx


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response