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

徘徊边缘 提交于 2019-12-01 18:08:56

问题


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:


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.



来源:https://stackoverflow.com/questions/5008826/retrieve-set-statistics-io-and-set-statistics-time-values-via-ado-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!