Sql-server – Stored Procedure Resultset Row Count and Resultset Size in Bytes/KBs

profilersql servert-sql

Is there any way to get total row count and size of result-set generated by a stored procedure execution?

@@ROWCOUNT is a good option if its already added in each stored procedure but I just want something like all RPC calls with in specific time period, with Row count and Size (in Bytes or KBs) for each call without modifying any stored procedure.

Best Answer

The question is unanswerable as asked since stored procedures do not produce result sets. Only (certain) statements produce result sets. Executing procedures may produce none, one or more results sets depending on the statements contained and the branches executed.

For statements the row count will be tracked in sys.dm_exec_query_stats.

Result sets have no size (in bytes or KB), size is an attribute pertinent only to encoding and representation. A sensible question would be to ask how many bytes are transferred between the client and the server, and this can be tracked by transport performance counters.