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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collect() a table to S...
Power Apps
Unanswered

Collect() a table to SQL Server - Is it making calls for each record?

(0) ShareShare
ReportReport
Posted on by 6

Hi,

 

I have data in a table on a MS SQL Server. I am collecting data in PowerApps and adding those records to the server table. The data i am collecting is pretty straightforward 4 colums and an integer in each. The number of records can vary between 2 and 300. 

sqlTable: ID (autoincrement), col1, col2, col3, col4, Date (getdate())
collectionTable: col1, col2, col3, col4

 

 

For this i am using a simple:

 

Collect('[dbo].[Table]';collectionTable)

The time it takes to complete this collect() rises incrementaly with the number of records. Collecting more than 30 records and the wait is rather unpleasent. Looking at the network traffic, it looks like its making a call for each record of the table. I thought the whole idea of using Collect() was that it only made a single server call?

 

Is there anything in the SQL table that affects collect()s ability to do a single call? Konstraints on the table or such?
If not, is there a better way to this?

 

Thanks in advance,

Categories:
I have the same question (0)
  • Meneghino Profile Picture
    6,949 on at

    Hi @August

    Unfortunately there is no easy fix for updating multiple records with one call, but please vote up this idea:

    https://powerusers.microsoft.com/t5/PowerApps-Ideas/Patch-multiple-records-with-one-server-call-instead-of-multiple/idi-p/74261

  • Verified answer
    Meneghino Profile Picture
    6,949 on at

    Actually I have thought ot a work-around, but have not tested it.  Basically, instead of using Collect to insert your data into SQL using the built-in functions (Collect or Patch, which both work poorly with multiple rows) then use Flow to parse JSON data instead, either in Flow itself or with a stored procedure in SQL Server.

     

    For example:

    1) In PowerApps, use the concatenation functions to create a JSON string with your multiple records to insert (hold that thought for later)

    2) In SQL Server create a stored procedure to parse the JSON string to insert records into your DB table using the OPENJSON function

    3) In Flow accept a string input from PowerApps and pass it as a parameter to the stored procedure called from SQL Database

    4) In PowerApps, add the Flow and supply the string from step 1 as a parameter

    5) In PowerApps, remember to Refresh your data source to see the changes to the table, as these will no longer be automatically reflected

     

    As an added bonus, you can return the result of the operation from SQL to Flow via OUTPUT parameters, and from Flow to PowerApps via the Return Response action.  See here for an example.

     

    Please let me know if you need more guidance on any of the steps

     

  • August Profile Picture
    6 on at

    Thanks Meneghino,

     

    I was thinking about similar workarounds myself. Even something as simple as just converting it to a mail and letting Flow do the rest from there. I will look into your suggestions and try the JSON way. Thank you for your help. 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard