cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MWISE
Advocate I
Advocate I

Create a Flow: Pull records from Azure SQL to CSV or Excel

Hello,

 

I have a project where I need to create a Flow that will pull the records from an Azure SQL db to a CSV or Excel file. We have mulitiple tables so if I need to create any queries I'll work with my BI team to create them. I just need a starting place for getting the flow created.

 

We may want both scheduled and a button trigger, so I assume I would create two different flows?

 

FYI... The project starts with a PowerApp where a salesperson enters forecast data each month and that gets stored in Azure. We need the flow to pull the data for all salespeople by region to send to the Planner. Phase 2 of the project may look at using a PowerApp for the planner but it's a lot of data to process so we're not sure yet.

 

Thank you.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @MWISE based on what I've read the following Flow should get you started. I haven't got a SQL database to connect to in order to provide more context to my screenshots, but the basic steps should get you going.

 

As you have two different starting triggers, you will need two different Flows. There are patterns that you can employ to be able to reuse Flows, but I'd start simple and once you have nailed your process then consider consolidating the logic.

 

The following Flow is based on a Flow Button manual trigger, although you could use a PowerApps instant trigger too if you wanted.

 

The first action will execute a SQL statement against a given database. There are alternative actions such as execute stored procedure which you could also employ to get your data from your database table.

 

I have then used an "Add new row to table" action for Excel in order to write the items from the database to Excel.

 

When I start taking dynamic content from the SQL action and adding to the Excel action, I would be expecting a loop to appear. This is perfectly normal as it will just loop through all of the items which have been retrieved from your SQL query.

 

Again, apologies that I can't give you something more concrete, but if you get stuck I'll go and run myself up an Azure SQL DB.

 

SQL.PNG

View solution in original post

2 REPLIES 2

Hi @MWISE based on what I've read the following Flow should get you started. I haven't got a SQL database to connect to in order to provide more context to my screenshots, but the basic steps should get you going.

 

As you have two different starting triggers, you will need two different Flows. There are patterns that you can employ to be able to reuse Flows, but I'd start simple and once you have nailed your process then consider consolidating the logic.

 

The following Flow is based on a Flow Button manual trigger, although you could use a PowerApps instant trigger too if you wanted.

 

The first action will execute a SQL statement against a given database. There are alternative actions such as execute stored procedure which you could also employ to get your data from your database table.

 

I have then used an "Add new row to table" action for Excel in order to write the items from the database to Excel.

 

When I start taking dynamic content from the SQL action and adding to the Excel action, I would be expecting a loop to appear. This is perfectly normal as it will just loop through all of the items which have been retrieved from your SQL query.

 

Again, apologies that I can't give you something more concrete, but if you get stuck I'll go and run myself up an Azure SQL DB.

 

SQL.PNG

View solution in original post

@MattWeston365 I finally got live data to test this with and it worked great! Thanks for your help!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (3,173)