cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lee
Kudo Collector
Kudo Collector

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

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

27 REPLIES 27
v-yamao-msft
Community Support
Community Support

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.

 

 

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 

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

Hiya Sameer

 

yep thought so 🙂 pity

 

Already beat you to it,

 

Stored procedure armed and ready.

 

Flow now working as before.

 

cheers

 

Lee

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 

 

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

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

agneum
Advocate V
Advocate V

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.

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).

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.

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
Frequent Visitor

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
Advocate I
Advocate I

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.

I guess its about time?

 

Me --> Slams head on a wall!!

Anonymous
Not applicable

Helllloooooo??????

 

@SameerCh 

I don't think it's a priority item to MS. Hope you can find an alternative workaround in your case. 

Stay safe, and good luck!

Hi Folks,

 

This is a really old thread.  Unfortunately, we still have the same limitations.  The challenge with Server side SQL triggers is precisely that we cannot find a way to get the data back.  And many of the experiences we have on Power Apps require that the data is sent back.

 

We now have a better workaround for at least some of the main use cases.  You can use a native SQL query to write the data to SQL. For example, you can use something like: INSERT INTO MyTable (Column1,...) VALUES ( value1, ...)

 

HTH

 

With all due respect, "this is a really old thread" is a wee bit inappropriate response, and I cringed when I read it. It's a painful issue for a select few customers, which is WHY it's an old thread.  Let's be fair, a newbie already feels intimidated, and it's not very, um, uplifting to tell them they are responding to old threads. (It's kind of demeaning actually. )Their frustrated, they need a Microsoft buddy who asks them how they can help. That's why their venting.  Ask him for his SQL so you can check it out before making a suggestion. He might even Kudo you..or he might help find the fix for the problem. At least offer to give him a few screen shots of your suggestion.

Peace,  

@SmartMeter

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Top Kudoed Authors
Users online (4,891)