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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get sql records and cr...
Power Automate
Unanswered

Get sql records and create excel/table for specific data

(0) ShareShare
ReportReport
Posted on by 258

Hi,

 

I have a sql table as follows,

Useritemprice
AItem12
BItem25
CItem36
AItem41
AItem57
CItem65
BItem78

 

Need to get this table and Using get rows able to get it done.

 

Next I need to send email for each users containing their item and price list in a excel as an attachment.

 

Ex - For the User "A" send an email with the following,

Useritemprice
AItem12
AItem41
AItem57

 

Is there any suggestion to make this work?

 

Thanks.

 

 

 

 

 

 

 

 

 

 

 

 

 

Categories:
  • Barret Profile Picture
    652 Most Valuable Professional on at

    The Power Automate Excel connector has a number of limitations to it, so this is is how I would approach it. Start by creating a blank Excel workbook with an empty named table to use as a template and store it somewhere Power Automate can copy it from from like OneDrive. Then, for the flow use the following steps:

     

    1. SQL Connector - Get list of users in database table
    2. For Each User:
      1. Create copy of Excel template workbook with a distinct name for that user
      2. SQL Connector: Get rows from database table for that user
      3. For each row: Excel Connector: Add row into named table
      4. Delay 10 minutes: Sometimes the Excel connector can hold open the file for a few minutes, causing anything after that to error.
      5. Send email to user with created Excel as attachment

     

  • sandeepstw Profile Picture
    312 Moderator on at

    Hi There,

     

    To send an email to each user containing their respective item and price list as an attachment in Excel format, follow the solution below using Power Automate:

    1. Retrieve data from SQL table: Use the "Get rows" action in Power Automate to retrieve the data from the SQL table. Configure the connection to the SQL database and specify the table from which you want to fetch the data.

    2. Group data by user: Utilize the "Group by" action to group the retrieved rows based on the "User" column. This will allow you to process the data for each user individually.

    3. Loop through each user group: Implement a "Apply to each" loop to iterate over each group of data, which represents each user's item and price list.

    4. Generate Excel table for each user: Inside the loop, create an Excel table that includes the "Item" and "Price" columns for the current user's group of data. You can use the "Create table" action to define the table structure.

    5. Convert Excel table to Excel file: Convert the Excel table generated in the previous step into an Excel file. Utilize the "Convert table to Excel" action to achieve this.

    6. Send email with Excel attachment: Use the "Send an email" action to send an email to the current user. Configure the necessary parameters such as recipient, subject, and body of the email. Attach the Excel file generated in the previous step as an attachment to the email.

    7. Complete the loop: The loop will automatically iterate through each user's group of data, generating separate Excel files and sending emails to each user individually.

    By following this solution, you will be able to send an email to each user containing their item and price list as an attachment in Excel format. The process involves retrieving the data from the SQL table, grouping it by user, generating an Excel table for each user, converting it to an Excel file, and sending the email with the attachment.

    Make sure to save and test your Power Automate flow to ensure it functions as expected.

     

    Please give kudos and mark as solution if it helps.

    Thanks,
    Sandeep Mishra

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 298 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard