Diagnostic tracing scopes

Following is the list of scopes for diagnostic tracing. Scope values can be used to limit tracing to who (or what) is causing the activity in the database. For example, you can set the scope to trace requests coming from a specified connection. Scope values are stored in the scope column of the dbo.sa_diagnostic_tracing_level diagnostic table, and may have corresponding arguments, typically an identifier such as an object name or user name, which are stored in the identifier column. The values in the scope column reflect the settings specified in the Database Tracing Wizard.

Values in the scope column Description
DATABASE

Records tracing data for any event occurring within the database, assuming the event corresponds to the specified level and condition. Used for long-term background monitoring of the database, or for short-term diagnostics, when it is necessary to determine the source of costly queries.

There is no identifier to specify when you specify DATABASE.

ORIGIN

Records tracing data for the queries originating from either outside or inside the database.

There are two possible identifiers you can specify when specifying the scope ORIGIN: External or Internal. External specifies to log the statement text and associated details for queries that come from outside the database server, and that correspond to the specified level and condition. Internal specifies to log the same information for queries that come from within the database server, and that correspond to the level and condition specified.

USER

Records tracing data only for the queries issued by the specified user, and by connections created by the specified user. This scope is used to diagnose problematic queries originating from a particular user.

The identifier for this scope is the user ID of the user for whom the tracing is to be performed.

CONNECTION_NAME, or CONNECTION_NUMBER

Records tracing data only for the statements executed by the current connection. These scopes are used when the user has multiple connections, one of which is executing costly statements.

The identifier for this scope is the name of the connection, or the connection number, respectively.

FUNCTION, PROCEDURE, EVENT, TRIGGER, or TABLE

Records tracing data for the statements that use the specified object. If the object references other objects, all the data for those objects is recorded as well. For example, if tracing is being done for a procedure that uses a function which, in turn, triggers an event, statements for all three objects are logged, providing they correspond to the specified level and condition provided for logging. Used when use of a specific object is costly, or when the statements that reference the object take an unusually long time to finish.

The TABLE scope is used for tables, materialized views, and non-materialized views.

The identifier for this scope is the fully qualified name of the object.

 See also