cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lee
Level 8

Insert into SQL table with active triggers implemented

Hi guys,

 

I can successfuly get flow to insert a row into one of my SQL tables. Now the issue I have is that I need to set up a trigger on this table to get the same data sent pover to  a different table on a different Server.

 

Since implementing the trigger Flow will not insert into the original table:

 

error:

 

"status": 400,

  "message": "Invalid Mashup Expression using supplied values.\r\n     inner exception: Microsoft SQL: The target table 'dbo.TABLE' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.",

  "source": "sqlconnectionprovider-westeurope.am2-ase-001.p.azurewebsites.net"

 

Is there any way around this please?

 

For the error I suspect that the SQL Flow generates in the back end to get the data into my table is the issue by not using the into clause when using the output clause?

 

many thanks

 

Lee

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Automate Staff SameerCh
Power Automate Staff

Re: Insert into SQL table with active triggers implemented

Lee,

 

You are right!  This is a current limitation on the SQL connector that updating a row do not work when the SQL Table has a SQL Trigger defined on it.  While we have plans on fixing this, we don't have a timeline yet.

There is no workaround for this today w/o making changes anything on the SQL side.

 

The feasible workarounds you can do are:

(1) Use a stored procedure

(2) Remove the trigger from your SQL Table

Obviously, (1) is the preferred method.  Let know if that works.

 

Thanks!
Sameer

View solution in original post

14 REPLIES 14
Community Support Team
Community Support Team

Re: Insert into SQL table with active triggers implemented

Hi Lee,

 

Which trigger are you using? I assume that your flow is relies on SQL Server, but currently, we do have actions for SQL Server, but we don’t have a trigger for it.

4.PNG

 

From the error message, it seems that your flow doesn’t have any enabled triggers. Please show me a screenshot of your flow for a further investigation.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Lee
Level 8

Re: Insert into SQL table with active triggers implemented

 

 

Lee
Level 8

Re: Insert into SQL table with active triggers implemented

Hi Mabel,

 

in the FLow: once an approval email has been approved I use Flow to move the data into a SQL table lets call it table 1.

 

that is the end of the Flow. this was working fine with no issues, data successfully getting inserted into table 1.

 

Now completetly outside / seperate of Flow  I needed to get the data from table 1 and insert the new row over to a seperate sql server db table (call it table 2) so I created a trigger on table 1 to get the data over to table 2. working fine as it is a simple after insert trigger on table 1. this was working when tested.

 

Now when I returned to flow and started a new flow I was then getting the error from FLow. After implementing the trigger on table 1 Flow was then unable to insert any data into table 1.

 

I presume when Flow creates the SQL to insert into table 1 it is using an output clause and no into clause within the same script which then stops flow from being able to insert the data

 

many thanks for your help.

 

please ignore the first reply, had an error half way through typing it and deleted it but it got posted in the end

 

many thanks

 

Lee 

Highlighted
Power Automate Staff SameerCh
Power Automate Staff

Re: Insert into SQL table with active triggers implemented

Lee,

 

You are right!  This is a current limitation on the SQL connector that updating a row do not work when the SQL Table has a SQL Trigger defined on it.  While we have plans on fixing this, we don't have a timeline yet.

There is no workaround for this today w/o making changes anything on the SQL side.

 

The feasible workarounds you can do are:

(1) Use a stored procedure

(2) Remove the trigger from your SQL Table

Obviously, (1) is the preferred method.  Let know if that works.

 

Thanks!
Sameer

View solution in original post

Lee
Level 8

Re: Insert into SQL table with active triggers implemented

Hiya Sameer

 

yep thought so 🙂 pity

 

Already beat you to it,

 

Stored procedure armed and ready.

 

Flow now working as before.

 

cheers

 

Lee

SmartMeter
Level 8

Re: Insert into SQL table with active triggers implemented

Hi @SameerCh, 

Is there any timeline on this as of 11/7/2017 ? I can certainly make a stored proc for this, but I would much rather leave my trigger in place, to propagate the updates on insertion, precisely when they are needed.

Many thanks, 

SmartMeter 

 

dhcinfotech
Level: Power Up

Re: Insert into SQL table with active triggers implemented

How soon are we getting this? Is there an update??? We NEED this.

dhcinfotech
Level: Power Up

Re: Insert into SQL table with active triggers implemented

How long before we get this? Any updates??? We NEED this.

agneum
Level 8

Re: Insert into SQL table with active triggers implemented

We're Q3 2018, any updates???


At the very least, can we get an explanation why even at all the connector cares about what's going on in the database layer? For updates/deletes it's primary concern should be to find the primary key, else seems completely unrelated.

briantbailey
Level: Powered On

Re: Insert into SQL table with active triggers implemented

When a CRUD operation is executed the command being sent includes the OUPUT clause. While normally all we think about caring about is the primary key being returned there may be a number of fields that are set during this process (for example, default dates) which PowerApps then wants to remain in synch with the DB. I am assuming that they use this approach to make the calls more efficient as only one call is executed using this method. The obvious drawback is that it cannot handle the triggers. In order to make a change to allow triggers there would have to be a redesign of the connector and the principal means by which the data in the entity/object is kept in synch. This could affect performance (multiple calls to the database) in order to accomodate triggers.

On a side note, if your SQL Server instance allows for Change Data Capture, this may be a viable alternative to triggers or moving to stored procedures. I have not tested it, but am looking at it to try and get around this issue without a bunch more code in Flow (or PowerApps).

briantbailey
Level: Powered On

Re: Insert into SQL table with active triggers implemented

When a CRUD operation is executed the command being sent includes the OUPUT clause. While normally all we think about caring about is the primary key being returned there may be a number of fields that are set or modified during this process (for example, default dates, function calls on columns) which PowerApps then wants to remain in synch with the DB. I am assuming that they use this approach to make the calls more efficient as only one call is executed using this method. The obvious drawback is that it cannot handle the triggers. In order to make a change to allow triggers there would have to be a redesign of the connector and the principal means by which the data in the entity/object is kept in synch. This could affect performance (multiple calls to the database) in order to accomodate triggers.

 

On a side note, if you are using triggers for auditing and your SQL Server instance allows for Change Data Capture, this may be a viable alternative to triggers or moving to stored procedures. I have not tested it, but am looking at it to try and get around an issue without a bunch more code in Flow or PowerApps.

SmartMeter
Level 8

Re: Insert into SQL table with active triggers implemented

I got over this bump in the road by using a "staging" table for my data, and sweeping this with a proc that inserted into the proper table. The table bound function was the sticky wicket. Fortunately we don't use these features often, but it was a pain, and delayed my implementation by a week! Thanks for the update!

charlied_mc
Level: Powered On

Re: Insert into SQL table with active triggers implemented

Any update on this? It's been almost 2 years at this point, we really should be able to use triggers in this way.

FBSEstimator
Level: Powered On

Re: Insert into SQL table with active triggers implemented

Can we get an update on this timeline.  It has now been over 2 years.  This is a pretty annoying thing that I need to run a flow to run a stored procedure rather than letting the database do the work.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (6,661)