{"title":"Analyze SQL query trace telemetry","url":"https://jonas-paprotka.de/docs/dev-itpro/administration/telemetry-sql-query-trace/","by":"JOP-AL","license":"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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/telemetry-sql-query-trace","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn about SQL query trace telemetry in Business Central","date":"2026-05-01","meta":{"topic":"how-to"},"outline":[{"level":1,"title":"Analyze SQL query trace telemetry","slug":"analyze-sql-query-trace-telemetry","at":0,"chars":4098},{"level":2,"title":"SQL query executed","slug":"sql-query-executed","at":796,"chars":3042},{"level":3,"title":"General dimensions","slug":"general-dimensions","at":892,"chars":328},{"level":3,"title":"Custom dimensions","slug":"custom-dimensions","at":1220,"chars":1782},{"level":3,"title":"Sample KQL code","slug":"sample-kql-code","at":3002,"chars":836},{"level":2,"title":"Related information","slug":"related-information","at":3838,"chars":260}],"text":"# Analyze SQL query trace telemetry\nAPPLIES TO: Business Central 2024 release wave 2 and later\nSQL 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.\n> NOTE\n> 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.\nFor more information about long-running SQL queries, see Analyzing Long Running Operation (SQL Query) Telemetry<telemetry-long-running-sql-query-trace>.\n## SQL query executed\nOccurs when a SQL statement is executed while verbose logging is enabled.\n### General dimensions\nDimension|Description or value\nmessage|Executed a SQL statement\nseverityLevel|0 (Verbose)\nuser_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.\n### Custom dimensions\nDimension|Description or value\naadTenantId|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.\nalObjectId|Specifies the ID of the AL object that executed the SQL statement.\nalObjectName|Specifies the name of the AL object that executed the SQL statement.\nalObjectType|Specifies the type of the AL object that executed the SQL statement.\nclientType|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>.\ncompanyName|The current company name.\ncomponent|Dynamics 365 Business Central Server\ncomponentVersion|Specifies the version number of the component that emits telemetry.\nenvironmentName|Specifies the name of the tenant environment. See Managing Environments<tenant-admin-center-environments>.\nenvironmentType|Specifies the environment type for the tenant, such as Production or Sandbox. See tenant-admin-center-environments#types-of-environments.\neventId|RT0009\nexecutionTime|Specifies the time it took to execute the SQL statement. The value has the format hh:mm:ss.sssssss.\nextensionId|Specifies the AppID of the extension that contains the AL object.\nextensionName|Specifies the name of the extension that contains the AL object.\nextensionPublisher|Specifies the publisher of the extension that contains the AL object.\nextensionVersion|Specifies the version of the extension that contains the AL object.\nsqlServerSessionId|Specifies the ID of the SQL Server session that executed the query.\nsqlStatement|Specifies the SQL statement that was executed. The value is limited to 8192 characters.\n### Sample KQL code\n```kql\ntraces\n| where timestamp > ago(1d) // SQL query traces generate high volume\n| where customDimensions.eventId == 'RT0009'\n| project timestamp\n, message\n, aadTenantId = customDimensions.aadTenantId\n, environmentName = customDimensions.environmentName\n, companyName = customDimensions.companyName\n, alObjectId = customDimensions.alObjectId\n, alObjectName = customDimensions.alObjectName\n, alObjectType = customDimensions.alObjectType\n, executionTime = customDimensions.executionTime\n, sqlStatement = customDimensions.sqlStatement\n```\n> TIP\n> 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.\nTo learn more about how to set up alerting on Business Central telemetry, see telemetry-alert.\n## Related information\nMonitoring and Analyzing Telemetry<telemetry-overview>\nAnalyzing Long Running Operation (SQL Query) Telemetry<telemetry-long-running-sql-query-trace>\nEnable Sending Telemetry to Application Insights<telemetry-enable-application-insights>"}