Skip to main content
Question

SQL Server T-SQL merge statement does not work in SQL Executor (FME 2024.0.2.2)

  • October 30, 2025
  • 4 replies
  • 41 views

aguan
Supporter
Forum|alt.badge.img+11

We upgraded FME from 2022.2.2 to 2024.0.2.2 one week ago, and I found out today the SQLExecutor gives an error for the SQL Server T-SQL Merger statement.  The SQLExecutor is set up as follows:

----------------------------------------------------------------------------------------------------------

FME_SQL_DELIMITER ;

use VENDOR_GLOBAL_SPGI;

MERGE INTO SPGI_INT.BLOCKS_VALID_INT AS t
USING (select distinct GA_ID,BLOCK_NAME,ONS_OFFSHORE from SPGI_INT.BLOCKS_VALID) AS s
ON t.GA_ID = s.GA_ID and t.BLOCK_NAME = s.BLOCK_NAME
WHEN MATCHED THEN
    UPDATE SET t.ONS_OFFSHORE = S.ONS_OFFSHORE;

--------------------------------------------------------------------------------------------------------

It gives this error:

Microsoft SQL Server Non-Spatial Reader: Query failed, possibly due to a malformed statement.  Query Text `MERGE INTO SPGI_INT.BLOCKS_VALID_INT AS t
USING (select distinct GA_ID,BLOCK_NAME,ONS_OFFSHORE from SPGI_INT.BLOCKS_VALID) AS s
ON t.GA_ID = s.GA_ID and t.BLOCK_NAME = s.BLOCK_NAME
WHEN MATCHED THEN
    UPDATE SET t.ONS_OFFSHORE = S.ONS_OFFSHORE'. Provider error `(-2147217900) A MERGE statement must be terminated by a semi-colon (;).'
An error has occurred. Check the logfile above for details

 

However, the Update and Delete statements work fine. For example, this sql works fine.

---------------------------------------------------------------------------------------------------

DELETE E
    FROM SPGI_INT.APPLICATIONS_VALID E
    INNER JOIN
    (
        SELECT objectid,
               ROW_NUMBER() OVER (PARTITION BY GA_ID order by date_of_last_load desc) as rank
        FROM SPGI_INT.APPLICATIONS_VALID
    ) T ON E.objectid = T.objectid
    WHERE rank > 1;

----------------------------------------------------------------------------------------------

Could this be a bug in 2024.0.2.2? I don’t think we had this issue in 2022.2.2.

 

Allen (allen.guan@woodside.com)

4 replies

crystalwang
Safer
Forum|alt.badge.img+14
  • Safer
  • October 31, 2025

Hi ​@aguan,

Thank you for providing the error message and your SQL statement. 

I believe the error is caused by the FME_SQL_DELIMITER being set to a semicolon (;). When this delimiter is used, FME splits the SQL query every time it encounters a semicolon and removes it before sending the statement to the database. As a result, the MERGE statement loses its required terminating semicolon, which causes the error.

The UPDATE and DELETE statements work because they don’t require a terminating semicolon, so using a semicolon as the FME_SQL_DELIMITER doesn’t affect them.

To resolve the issue, I recommend changing the FME_SQL_DELIMITER to a different value. This will ensure that the terminating semicolon in your MERGE statement is preserved.

Hope this helps!


aguan
Supporter
Forum|alt.badge.img+11
  • Author
  • Supporter
  • November 4, 2025

@crystalwang I tried ! and # for FME_SQL_DELIMITER, both give the same error for merge, but fine with delete. Hope Safe can do a simple test of this transformer on sql server merge statement. 


aguan
Supporter
Forum|alt.badge.img+11
  • Author
  • Supporter
  • November 4, 2025

@crystalwang I misunderstood. I need to terminate the merge with ;!, not !. It works now. Thanks.


crystalwang
Safer
Forum|alt.badge.img+14
  • Safer
  • November 6, 2025

No problem, ​@aguan. I’m glad to hear that it’s working now!