Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

retrieve SET STATISTICS IO and SET STATISTICS TIME values via ADO.NET?

When executing T-SQL queries via Management Studio, I can use SET STATISTICS IO ON and SET STATISTICS TIME ON to capture statistics for query tuning.

How can I gather the same statistics info when I'm using .NET client APIs to execute T-SQL queries instead of using Mangaement Studio's UI?

This seems like an obvious thing to be able to do, but after searching MSDN and Google for quite a while, I'm stumped. The closest thing I found was Provider Statistics for SQL Server (ADO.NET) on MSDN, but those stats seem to be client-side stats about network connectivity (e.g. bytes sent/received) from the client's perspective, not the server-side statistics I'm looking for.

like image 874
Justin Grant Avatar asked Oct 11 '22 16:10

Justin Grant


1 Answers

See the answer to this question.

The statistics info is just stored in the messages tab.

If you use SET STATISTICS... with this method you should be able to get what you are after.

like image 182
JNK Avatar answered Oct 21 '22 03:10

JNK