{"title":"Debugger.EnableSqlTrace(Integer [, Boolean]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/debugger/debugger-enablesqltrace-method/","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/developer/methods-auto/debugger/debugger-enablesqltrace-method, 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/developer/methods-auto/debugger/debugger-enablesqltrace-method","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":"Enables or verifies SQL tracing.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Debugger.EnableSqlTrace(Integer [, Boolean]) Method","slug":"debuggerenablesqltraceinteger-boolean-method","at":0,"chars":2166},{"level":2,"title":"Syntax","slug":"syntax","at":300,"chars":107},{"level":2,"title":"Parameters","slug":"parameters","at":407,"chars":1113},{"level":2,"title":"Return Value","slug":"return-value","at":1520,"chars":74},{"level":2,"title":"Remarks","slug":"remarks","at":1594,"chars":436},{"level":2,"title":"Related information","slug":"related-information","at":2030,"chars":136}],"text":"# Debugger.EnableSqlTrace(Integer [, Boolean]) Method\n> Version: _Available or changed with runtime version 1.0 until version 15.0 where it was deprecated._\nEnables or verifies SQL tracing. If you enable SQL tracing, then SQL Server events for selected sessions on the server instance are collected.\n## Syntax\n```al\n[IsEnabled := ]  Debugger.EnableSqlTrace(SessionID: Integer [, NewIsEnabled: Boolean])\n```\n## Parameters\nSessionID\nType: ../integer/integer-data-type\nThe ID of the session for which you want to enable the SQL trace, or for which you want to verify if tracing is enabled.If you specify 0 and you specify the NewIsEnabled parameter, then tracing is enabled for all existing sessions and all new sessions on the current server instance. If you specify 0 and you omit the NewIsEnabled parameter, then the function returns true if tracing is enabled for new sessions on the current server instance. If the session ID that you specify does not exist and you specify the NewIsEnabled parameter, then a run-time error occurs. If the session ID that you specify does not exist and you do not specify the NewIsEnabled parameter, then the function returns false.\n*[Optional] NewIsEnabled*\nType: ../boolean/boolean-data-type\nIf you specify the optional NewIsEnabled parameter, then the method sets whether tracing is enabled. true if you want to enable tracing for the specified session; false if you want to disable tracing. If you omit the NewIsEnabled parameter, then the function verifies if tracing is enabled.\n## Return Value\n*[Optional] IsEnabled*\nType: ../boolean/boolean-data-type\n## Remarks\nYou use Microsoft SQL Server Profiler to view traces. See Using SQL Server Profiler<https://learn.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms187929(v=sql.105)>. To start SQL Server Profiler, in SQL Server Management Studio, on the Tools menu, choose SQL Server Profiler.\nYou can also enable and disable SQL tracing by using the Start Full SQL Tracing and Stop Full SQL Tracing buttons on the Session List page.\n## Related information\ndebugger-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}