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

2.6k views Asked by At

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.

1

There are 1 answers

1
JNK On BEST ANSWER

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.