SET NOCOUNT ON and ASYNC_NETWORK_IO
SET NOCOUNT ON
From BOL , SET NOCOUNT ON the count is not returned. When is OFF, the count is returned.
Additional, prevents the sending of DONE_IN_PROC messages to the client . This is used within stored procedures and triggers to avoid showing the affected rows message. (XXX rows affected)
So , after every statement , in a stored procedure or trigger, sql server sends a message DONE_IN_PROC (rows affected) .With SET NOCOUNT ON, you can suppress these messages.
If you are not in a stored procedure , if you are in a batch , SQL Server sends DONE message/token for each statement. This can lead (in case of client not consume it fast) to waits s ASYNC_NETWORK_IO. To reduce it , you can use a temp stored procedure or sp_executeSQL .
When a statement is executed, the result ends with a DONE, DONEPROC, or DONEINPROC, depending of the where this statement is: stored procedure, batch…
- DONE_IN_PROC, DONE_PROC are sent for statements executed in stored procedures , triggers
- DONE are sent for statements executed in batch
Conclusion:
SET NOCOUNT ON , suppress only DONE_IN_PROC and not DONE messages.
S

