'How to Insert and/or Update Row in SQL using Microsoft Flow Power Automate when an Item in SharePoint is created or modified?

I just started creating my first Flow in Power Automate. The goal is to create / update a record in SQL when an entry in a SharePoint online list is created OR modified. Ultimately I want to also delete the record in SQL if its deleted in SharePoint.

I see that the SQL Update, Insert and Delete options are all separate in Flow but I want to create an all in one flow that can do all of those.

I got the Create / Update to work successfully but don't think (pretty sure) that this is not the best method. What I did is start with a condition where I am comparing Created and Modified date in the SharePoint list because in most cases when a new record is created both are equal to each other.

There must be a better way and this still doesn't help me with how to also handle the Delete piece without creating a separate flow for the same list.

Any advise is appreciated. Here is how my flow looks now and so far it worked for updating an existing record and creating new one. Both got reflected in SQL properly

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source