HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Does the command SET STATISTICS...ON turn statistics information on for all queries running throughout the server or just the current connection?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
turntheallqueriesjuststatisticsrunningfordoescurrent

Problem

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.

Solution

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

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

Context

StackExchange Database Administrators Q#255312, answer score: 5

Revisions (0)

No revisions yet.