5

In regards to SET STATISTICS TIME ON and SET STATISTICS IO ON I noticed in the remarks of the Microsoft doc, it says the following:

When STATISTICS IO is ON, statistical information is displayed, and when OFF, the information isn't displayed.

After this option is set ON, all Transact-SQL statements return the statistical information until the option is set to OFF.

Does that mean all Transact-SQL statements that execute in the current connection, or across the whole server? When I tested it myself, it seemed to be only within the scope of my connection.

  • 3
    The Transact-SQL programming language provides several SET statements that change the current session handling of specific information. SET Statements – Denis Rubashkin Dec 10 '19 at 16:03
5

The answer to the question can be found higher up the document tree:

enter image description here

SET statements:

The Transact-SQL programming language provides several SET statements that change the current session handling of specific information. The SET statements are grouped into the categories shown in the following table.

Which explains that all these set statements are applied to the current session.

With the category for SET STATISTICS IO,TIME ON; being statistics statements

enter image description here

  • So it's no big deal then in an ad-hoc query session if I left SET STATISTICS...ON for a while, since as long as I'm not actively running any queries in that session, nothing should be affected by it outside of my session? – J.D. Dec 10 '19 at 16:22
  • 1
    @J.D. That is correct :) – Randi Vertongen Dec 10 '19 at 18:43
3

This relates to "all Transact-SQL statements that execute in the current connection"
"only within the scope of my connection"

NOT across the whole server

  • 2
    I would stick to current session than connection. – Learning_DBAdmin Dec 10 '19 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.