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 / SQL Query results into...
Power Automate
Answered

SQL Query results into an Excel shows up without Headers

(0) ShareShare
ReportReport
Posted on by 21

Hello 

 

As the subject stated and the screen below i am basicaly doing the following 

- Extract from SQL

- Write into Excel

- Send results through an email 

 

Everything going fine except the results comes to the Excel without Headers or column names , i believe i have to do something else in the ( Write to Excel worksheet ) Action .

 

Thank you

 

 

Waleed65_0-1719380065562.png

 

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @Waleed65 ,

     

    You have 2 methods to achieve this.Please find the solution.

     

    1. The simplest way to pull data with header is you just need to change the header in connection staring to "NO" (HDR=NO) as shown in below image.

    VishnuReddy1997_0-1719385759114.png

     

    2. You try writing headers first by using %QueryResult2.ColumnHeadersRow% later the remaing data as shown in below image.

    VishnuReddy1997_1-1719385880479.png

    Code:

    SET Excel_A_File_Path TO $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\Practice\\Database\\Excel A.xlsx'''
    SET OLEDB_ConnectionString TO $'''Provider=Microsoft.ACE.OLEDB.12.0;Data Source=%Excel_A_File_Path%;Extended Properties=\"Excel 12.0 Xml;HDR=YES\";'''
    Database.Connect ConnectionString: OLEDB_ConnectionString Connection=> SQLConnection
    @@copilotGeneratedAction: 'False'
    Database.ExecuteSqlStatement.Execute Connection: SQLConnection Statement: $'''SELECT * FROM [Sheet2$];''' Timeout: 30 Result=> QueryResult2
    Excel.LaunchExcel.LaunchUnderExistingProcess Visible: True Instance=> ExcelInstance
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: QueryResult2.ColumnHeadersRow Column: $'''A''' Row: 1
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: QueryResult2 Column: $'''A''' Row: 2
    Database.Close Connection: SQLConnection

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

     

     

     

  • Verified answer
    Waleed65 Profile Picture
    21 on at

    2nd method worked like a charm simple and easy which you just have to apply the write action twice .

     

    Thank you

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
Mohsin Ali Profile Picture

Mohsin Ali 426

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard