Get SET STATISTICS IO and SET STATISTICS TIME values ​​via ADO.NET?

When executing T-SQL queries through Management Studio, I can use SET STATISTICS IO ON and SET STATISTICS TIME ON to collect statistics to configure the query.

How can I collect the same statistics when I use the .NET APIs to execute T-SQL queries instead of using the Mangaement Studio interface?

This seems like an obvious thing that can be done, but after a long search of MSDN and Google, I am at a dead end. The closest I found is Provider Statistics for SQL Server (ADO.NET) on MSDN, but these statistics seem to be client statistics about the network (for example, sent and received bytes) from the client's point of view, not the statistics on server side I'm looking for.

+4
source share
1 answer

See the answer to this question.

Statistics information is simply stored in the message tab.

If you use SET STATISTICS... with this method, you can get what you need.

+4
source

Source: https://habr.com/ru/post/1339887/


All Articles