Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Everyone,

I was going through lot of articles and found that
SET NOCOUNT ON;
is recommended when you are working with stored procedures, but I mostly use stored procedure for CRUD operations, My Question is what if i want to retrieve some data using stored procedure, and put that in front end using VB.Net, as the no count is set to on it will only display the message that N rows affected. How can i get the data which i want by keeping the SET NOCOUNT ON.

Maybe many of you will find this question very basic but this is just a little confusion I am having.

Thank you

What I have tried:

Tried the temporary table but not much helpful
Posted
Updated 4-Jan-18 8:02am
v2
Comments
RedDk 4-Jan-18 13:46pm    
NOCOUNT is only a message shim.

SSMSE generates a lot of code upon right-clicks, much of it contains just such a NOCOUNT statement. 'Probably the place where the authors of a "lot of articles" were infected by the notion that there was something special about it.

Ignore it.

1 solution

Take a look at MSDN documentation[^]:

Quote:
Stops the message that shows the count of the number of rows affected by a Transact-SQL statement or stored procedure from being returned as part of the result set.
...
SET NOCOUNT ON prevents the sending of DONE_IN_PROC messages to the client for each statement in a stored procedure. For stored procedures that contain several statements that do not return much actual data, or for procedures that contain Transact-SQL loops, setting SET NOCOUNT to ON can provide a significant performance boost, because network traffic is greatly reduced.


Conclusion: Using SET NOCOUNT ON is strongly recommended.

There's tons of myth about this instruction. I'd suggest to read:
SQL SERVER - Effect of SET NOCOUNT on @@ROWCOUNT - SQL Authority with Pinal Dave[^]
Performance Surprises and Assumptions : SET NOCOUNT ON - SQLPerformance.com[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900