Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

SQL Insert Fails after Condition



I am building a flow that pulls data from Dynamics using a trigger that pulls data when we get an Insert or an Update in dynamics.  I then query my sql table using the ID from the trigger to determine if the row is in the table or not.  If the row is in the table I send the row down an Update path and if it is not in the table it goes down an Insert path.  Here is the flow.
Flow Insert.PNG

The flow however fails on the insert.  The condition seems to be the cause of the problem.  I am using this code 

"empty(body('Get_rows')?['value'])" to determine if my query returned any results.  It seems to push it down the insert path but fails on a 400 error saying "The key didn't match any rows in the table \r\n".  I tested the insert above the Get Rows and it works fine there.  The insert is working correctly.  It appears my condition statement is causing the problem.  Any ideas I can use that will allow me get this to run both on the Insert and on the Update?Flow Error 1.PNGFlow Error 2.PNG

 Flow Error 3.PNG

Community Support Team
Community Support Team

Re: SQL Insert Fails after Condition

Hi @johngabbradley,


Could you please share a full screenshot of the configuration of the "Insert Asset Stage" action in the flow?

Could you please share the full error message of the  "Insert Asset Stage" action when the action run failed?


Please share more details so we would try to provide a proper workaround for you.


Best regards,