Some traces are not being processed (failed to collect trace file). The ApexSQLAudit.log shows "Cannot parse SQL text data": and the traces are moved to quarantine folder
Example of the error:
2025-02-05 16:22:30.856 ERROR [ERPDATA]: An exception occurred
Cannot parse SQL text data
Type: ApexSQL.Audit.Processor.Distributed.Trace.TraceException
Stack trace
at ApexSQL.Audit.Processor.Distributed.Parser.SqlParserHelper.GetParsedObject(String sql, Boolean parseColumns)
2025-02-05 16:22:30.915 ERROR [ERPDATA]: An exception occurred
Cannot parse SQL text data
Type: ApexSQL.Audit.Processor.Distributed.Trace.TraceException
Stack trace
at ApexSQL.Audit.Processor.Distributed.Parser.SqlParserHelper.GetParsedObject(String sql, Boolean parseColumns)
at ApexSQL.Audit.Processor.Distributed.Parser.SqlParserPool.GetParsedObject(String sql, Boolean parseColumns)
at ApexSQL.Audit.Processor.Distributed.ExtendedEvents.XeParser.ParseXeMissingData(AuditEvent auditEvent)
at ApexSQL.Audit.Processor.Distributed.ExtendedEvents.XeParser.ParseXeEvent(EventSession event)
at ApexSQL.Audit.Processor.Distributed.ExtendedEvents.XeParser.Parse(EventFileInfo file, List`1 events)
2025-02-05 16:25:15.728 ERROR [ERPDATA]: An exception occurred
Cannot parse SQL text data
Type: ApexSQL.Audit.Processor.Distributed.Trace.TraceException
Stack trace
at ApexSQL.Audit.Processor.Distributed.Parser.SqlParserHelper.GetParsedObject(String sql, Boolean parseColumns)
2025-02-05 16:25:15.728 ERROR [ERPDATA]: An exception occurred
Cannot parse SQL text data
Type: ApexSQL.Audit.Processor.Distributed.Trace.TraceException
Stack trace
at ApexSQL.Audit.Processor.Distributed.Parser.SqlParserHelper.GetParsedObject(String sql, Boolean parseColumns)
at ApexSQL.Audit.Processor.Distributed.Parser.SqlParserPool.GetParsedObject(String sql, Boolean parseColumns)
at ApexSQL.Audit.Processor.Distributed.ExtendedEvents.XeParser.ParseXeMissingData(AuditEvent auditEvent)
at ApexSQL.Audit.Processor.Distributed.ExtendedEvents.XeParser.ParseXeEvent(EventSession event)
at ApexSQL.Audit.Processor.Distributed.ExtendedEvents.XeParser.Parse(EventFileInfo file, List`1 events)
There is a T-SQL query which contains a procedure call with a hyphen (-) in the procedure name without double quotes or brackets and the SQL Parser throws a syntax error for it.
Note that, even though there is a bug to address the issue, this is not a valid SQL because hyphens are interpreted as a subtraction operator in T-SQL. To use a hyphen (-) in the name, it needs to be enclosed in square brackets [ ]. This is easy to test in SSMS: just create a procedure with a hyphen in its name and execute it.
Example of the error SQL Parser throws
2025-03-18 16:00:33.561 DEBUG [XXX\YY]: SQL Parser exited with code 1
2025-03-18 16:00:33.562 DEBUG [XXX\YY]: syntax error, state:871(10101) near: GenViaEmail(1,20)
2025-03-18 16:00:33.562 DEBUG [XXX\YY]: SQL Query: exec example_proc-proc @EmailFrom=N'',
@Subject=N'Exception While example From Email',@Body=N'System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file
''C:\example-17-03-2025.xlsx''. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
at ReadingEmailGraphAPI.Program.Func_ExceltoXML(String FilePath, Int32 intSheet) in D:\OneDrive - NIIT Limited\ReadingEmailGraphAPI\ReadingEmailGraphAPI - NLSL\Program.cs:line 178
at ReadingEmailGraphAPI.Program.ReadingEmail() in D:\OneDrive - NIIT Limited\ReadingEmailGraphAPI\ReadingEmailGraphAPI - NLSL\Program.cs:line 114',@ErrorFlag=N'Y'
WORKAROUND
None
STATUS
Created BUG 236621 : SQL Parser throws a syntax error for a T-SQL query which contains a procedure call with a hyphen (-) in the procedure name without double quotes or brackets
Waiting for fix in a future release of ApexSQL Audit.
© ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center