Is it possible to access the SQL Server ‘by-product messages’ via ADO.NET? Due to the lack of words, by ‘by-product messages’ I mean the output which appears in the Messages tab in Microsoft SQL Server Management Studio. What I particularly have it mind is to read the output of SET STATISTICS TIME ON. It appears that SqlDataReader does not offer anything in this matter.
Share
Yes, there’s an event on the
SqlConnectionclass calledSqlInfoMessage, which you can hook into:The event handler will look like this:
The
e.Messageis the message printed out to the message window in SQL Server Management Studio.