For those of you starting out. Have you ever wondered why so many stored procedures start with SET NOCOUNT ON?

SET NOCOUNT ON stops the message that shows the count of the number of rows affected by a SQL statement. Note that the @@ROWCOUNT function is updated regardless of how we set NOCOUNT.

If you have a stored procedure that makes a lot of selects then you may want to set nocount on to avoid confusion on your final return.


SET NOCOUNT ON — Stops showing the message (N row(s) affected)

SET NOCOUNT OFF — Shows the message (N row(s) affected)

Leave a Reply

Your email address will not be published. Required fields are marked *

9 + 1 =

Post Navigation