Why is the speed of executing statements dependent on the network connection?
There is obviously some communication going on between SQL Server and the client that directly is dependent on the number of statements executed.


Yes, there is. By default, SQL Server sends a TDS DONE_IN_PROC message after every statement in a stored procedure. The message communicates status and row count information for the completed statement to the client.

You can suppress the sending of these messages using the T-SQL command:

SET NOCOUNT ON;


The following is an extract (my emphasis) from the Books Online entry for this command:


  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.


Related Q &amp; A: Why does a simple loop result in ASYNC_NETWORK_IO waits?