# Analyze SQL query trace telemetry
APPLIES TO: Business Central 2024 release wave 2 and later
SQL query trace telemetry provides verbose logging of all SQL queries executed by Business Central. This telemetry is only emitted when verbose logging is enabled from the Help & Support page or through the Business Central admin center.
> NOTE
> SQL query trace (RT0009) is different from long-running SQL query telemetry (RT0005). The long-running SQL query telemetry is always enabled and captures queries exceeding a threshold (default 750 ms). SQL query trace captures all queries when verbose logging is active, regardless of execution time.
For more information about long-running SQL queries, see Analyzing Long Running Operation (SQL Query) Telemetry<telemetry-long-running-sql-query-trace>.
## SQL query executed
Occurs when a SQL statement is executed while verbose logging is enabled.
### General dimensions
Dimension|Description or value
message|Executed a SQL statement
severityLevel|0 (Verbose)
user_Id|The user telemetry ID for the user. From the user card, you can use user_Id to identify the user who triggered this telemetry event. See telemetry-enable-application-insights#assign-a-telemetry-id-to-users.
### Custom dimensions
Dimension|Description or value
aadTenantId|Specifies the Microsoft Entra tenant ID used for Microsoft Entra authentication. For on-premises, if you aren't using Microsoft Entra authentication, this value is common.
alObjectId|Specifies the ID of the AL object that executed the SQL statement.
alObjectName|Specifies the name of the AL object that executed the SQL statement.
alObjectType|Specifies the type of the AL object that executed the SQL statement.
clientType|Specifies the type of client that opened the session, such as Background or Web. For a list of the client types, see ClientType Option Type<../developer/methods-auto/clienttype/clienttype-option>.
companyName|The current company name.
component|Dynamics 365 Business Central Server
componentVersion|Specifies the version number of the component that emits telemetry.
environmentName|Specifies the name of the tenant environment. See Managing Environments<tenant-admin-center-environments>.
environmentType|Specifies the environment type for the tenant, such as Production or Sandbox. See tenant-admin-center-environments#types-of-environments.
eventId|RT0009
executionTime|Specifies the time it took to execute the SQL statement. The value has the format hh:mm:ss.sssssss.
extensionId|Specifies the AppID of the extension that contains the AL object.
extensionName|Specifies the name of the extension that contains the AL object.
extensionPublisher|Specifies the publisher of the extension that contains the AL object.
extensionVersion|Specifies the version of the extension that contains the AL object.
sqlServerSessionId|Specifies the ID of the SQL Server session that executed the query.
sqlStatement|Specifies the SQL statement that was executed. The value is limited to 8192 characters.
### Sample KQL code
```kql
traces
| where timestamp > ago(1d) // SQL query traces generate high volume
| where customDimensions.eventId == 'RT0009'
| project timestamp
, message
, aadTenantId = customDimensions.aadTenantId
, environmentName = customDimensions.environmentName
, companyName = customDimensions.companyName
, alObjectId = customDimensions.alObjectId
, alObjectName = customDimensions.alObjectName
, alObjectType = customDimensions.alObjectType
, executionTime = customDimensions.executionTime
, sqlStatement = customDimensions.sqlStatement
```
> TIP
> Be careful when analyzing RT0009 events as they can generate large volumes of data. Always limit your query time range and consider filtering by specific objects or sessions.
To learn more about how to set up alerting on Business Central telemetry, see telemetry-alert.
## Related information
Monitoring and Analyzing Telemetry<telemetry-overview>
Analyzing Long Running Operation (SQL Query) Telemetry<telemetry-long-running-sql-query-trace>
Enable Sending Telemetry to Application Insights<telemetry-enable-application-insights>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/telemetry-sql-query-trace, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/administration/telemetry-sql-query-trace/
