Skip to content
+1-888-319-3663

COMMUNITY FORUM

Error saving globallasterror from Business Central to SQL

asked 11 months ago

Hello,

I am importing documents from SQL to Business Central, but when the transaction has an error, I want to save the error message in the SQL source table. When the error message has the ‘ character the task for updating the error message I have syntax error.

I tried to replace the ‘ using SQL statements but I have the same error.

The error message is like this… “Failed to create record. Direct Posting must be equal to ‘Yes’ in G/L account No. XXXXX”

and the error I get is Error near to ‘Yes’

Any Idea how I can save the error message in SQL when it has this character?

 

Thanks!

Answers
Ethan Sorenson Staff answered 3 months ago

You can do this two ways.

  1. Use a scripting task before the sql task to replace all single quotes with double quotes
  2. Modify your script to turn off quoted identifiers before inserting the vlaue.
SET QUOTED_IDENTIFIER OFF;
update [TEST].[dbo].[ERRORS]
set Name = "Failed to create record. Direct Posting must be equal to 'Yes' in G/L account No. XXXXX"
where id = '01D8EAA5-C732-EA11-A813-000D3A6523B2'
SET QUOTED_IDENTIFIER ON;

If you would like to submit an answer or comment, please sign in to the eOne portal.