web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power Automate Upsert ...
Power Automate
Answered

Power Automate Upsert sql server

(0) ShareShare
ReportReport
Posted on by 168

Hello,

I have the following error for the flow 'run sql request':

Incorrect syntax near the keyword 'ON'.
clientRequestId: 5fd63968-323f-4692-be74-e48aa4790cfb

 

djidji_0-1675683530253.png

I checked the syntax and there is no error, I try to make an upsert in sql.

I don't know where could be the error.

 

Here the request content:

 

 

 

 

INSERT INTO
 dim_customer_contract (
 idcustomer,
 Distribution_contract,
 contract_std,
 QTA,
 QTA_Type
 )
VALUES
 (
 '0000600029',
 'Yes',
 'old standard',
 '',
 ''
 ),(
 '0000600029',
 'Yes',
 'old standard',
 '',
 ''
 ) ON DUPLICATE KEY
UPDATE;

 

 

 

 

 

Thank you for your help.

Categories:
  • Verified answer
    djidji Profile Picture
    168 on at

    Ok the 

    ON DUPLICATE KEY
    UPDATE;

    Not working with sql-server, I don't know why everSQL said there is no error with this version of sql.

    The solution:

    MERGE dim_customer_contract AS target
    USING (VALUES@{variables('tableUpsertFormatted')}) AS source (idcustomer,Distribution_contract,contract_std,QTA,QTA_Type)
    ON target.idcustomer = source.idcustomer
    WHEN MATCHED THEN
    	UPDATE SET target.idcustomer = source.idcustomer, target.Distribution_contract = source.Distribution_contract, target.contract_std = source.contract_std, target.QTA = source.QTA, target.QTA_Type= source.QTA_Type
    WHEN NOT MATCHED BY TARGET THEN
    	INSERT (idcustomer,Distribution_contract,contract_std,QTA,QTA_Type)
    	VALUES (source.idcustomer, source.Distribution_contract, source.contract_std,source.QTA,source.QTA_Type);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 445

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 300

Last 30 days Overall leaderboard