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 Automate / How to append SQL quer...
Power Automate
Unanswered

How to append SQL query result to file without adding the column headings

(0) ShareShare
ReportReport
Posted on by 68

Hi, I have a flow that retrieves data from sql via a stored procedure with the intention of generating a CSV output file. Due to the size of the dataset, the execute sql stored procedure is run multiple times, returning 5000 records at a time. Every time a batch of 5000 records is returned it is converted into a csv table and appended to the file. 

The issue I have is that each time the batch is appended to the file the column headers are also appended. How can I append the data to the file but exclude the column headers. 

Categories:
I have the same question (0)
  • lbendlin Profile Picture
    8,474 Super User 2025 Season 2 on at

    After the first run issue a skip(...,1)  on the result array before appending that .

  • ianselbyuk Profile Picture
    68 on at

    Hi so I am not using an array, the steps I have in the flow are as follows.

    ianselbyuk_0-1696924813253.png

     

  • lbendlin Profile Picture
    8,474 Super User 2025 Season 2 on at

    I'm pretty sure that the output of "Create CSV table 2"  is an array.  Check the raw output.

  • ianselbyuk Profile Picture
    68 on at

    Hi it doesn't look like an array see the start section below more like a csv file though starting with {"body":

    {"body":"Doc Date,DocumentNo,Text,Amount in DC,Curr,Net Due Date,Reference,Account,Franchise No,Date Today,Days Due,CRG,Type,DS Customer Type,Leaving Date,Title,First Name,Surname,Date Of Birth,Relevent Tab,Street,City,Post Code,Telephone Number,Email Address,Franchise Start Date,No Of Times,Arrears (SAP),NYD,Total Debt (Helix and SAP),Category,Weekly Franchise Cost,Brand,Greater Than 4x WFF,Franchise Agreement Number,Edge Case Reason,NYD PP,NYD PP Start Date\r\n

    When I try to using a skip(outputs('Create_CSV_table_2'),1) I get the following error

    InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'skip' expects its first parameter 'collection' to be an array or a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#skip for usage details.'.
     

  • lbendlin Profile Picture
    8,474 Super User 2025 Season 2 on at

    ok, how about the "Parse JSON"  output?

  • ianselbyuk Profile Picture
    68 on at

    I tried that but couldnt get it to work. I think the issue is that the output of the Parse JSON is an array of objects from key value pairs. If I skip the first (not that it would let me use the skip formula) I lose a row of data, and the create csv table would likely just regenerate the headings from the key value pairs of the next item.

    {"body":[{"Doc Date":"2023-08-03","DocumentNo":"","Text":"Lesson claimed in error: 03/08/2023
  • lbendlin Profile Picture
    8,474 Super User 2025 Season 2 on at

    Fair enough.  

     

    How about this - ingest the outputs('Create_CSV_table_2') into an array (using split on \r\n) then skip (...,1) and then stitch the string back together again with \r\n  ?

  • ianselbyuk Profile Picture
    68 on at

    That might work, i will give it a try.  for all the power of powerautomate and how it tries to simplify things I am a little bemused how problematic it has been to take batches of sql data and output it as a single csv file.

    I will give your suggestion a go and update here on the results but thanks for all your help in the meantime

     

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard