Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

Extract data from SQL and create text file

I’ve been trying to figure out how to achieve this using Flow, but im drawing a blank. Here’s my story, and refer to the screenshot below.


I have 4 SQL tables containing info. Three of them contain their own info, and a 4th which links the other 3. Its actually a dynamics crm database, and by links I mean relationships, but its all the same. Im looking to generate a text file output in a specific format using info from all 4 tables. For example, say I have the following tables.


  1. Table1 – ColumnB
    1. 1234
    2. 4567
  2. Table2 – ColumnB
    1. Name1
    2. Name2
  3. Table3 – ColumnB
    1. UsageType1
    2. UsageType2
  4. Table4 (linking the above 3 tables) – ColumnB – ColumnC – ColumnD
    1. 1234 – Name1 – UsageType1
    2. 4567 – Name1 – UsageType2
    3. 1234 – Name2 – UsageType1
    4. 1234 – Name1 – UsageType2
    5. Or any other combination.


I now wish to generate the following text files:

  1. FileName: Name1.txt







  1. FileName: Name2.txt





Community Support Team
Community Support Team

Re: Extract data from SQL and create text file

Hi @JoeO ,


Although you have provided a lot of information, I still don't understand whether the files you create have any rules.

Please provide more detail about your needs.


Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

Re: Extract data from SQL and create text file



If by "rule" you're referring to the rule table in my example, the answer is no. The rule becomes the name of the text file.  So for example, say i have a row in Table2 called "Test", then the file name becomes Test.txt. 

Helpful resources


Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!


Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!


New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!


Power Automate Community User Group Member Badge

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


Microsoft Learn

Learn how to build the business apps that you need.


Power Platform World Tour

Find out where you can attend!


Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (5,035)