Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to import multiple SQL statements in an Excel file?

Hello

 

I have several SQL statments that I need to load into Excel sheets in an Excel file.

 

Can you tell me how to do that smartly please without having to put them one by one?

 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous 

 

As far as I know, there isn't a smart way other than doing it 1 by 1, you can only select one worksheet to implement a statement at a time:

How to Embed a SQL Query in Microsoft Excel: 13 Steps (wikihow.com)


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@Anonymous 

 

As far as I know, there isn't a smart way other than doing it 1 by 1, you can only select one worksheet to implement a statement at a time:

How to Embed a SQL Query in Microsoft Excel: 13 Steps (wikihow.com)


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

mahoneypat
Microsoft Employee
Microsoft Employee

You want to pull the SQL from the text file and then execute them in the query editor?  Or are you willing to manually make each query using those SQL queries within the same workbook?  The latter is easy, the former is trickier but doable.

 

For the former, you just need to put your SQL into the Advanced options box for each query.  Here is a link.

Power Query SQL Server connector | Microsoft Docs

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Microsoft Employee
Microsoft Employee

Not sure what you mean.  Please clarify.  You have multiple SQL statements and you want to load them into separate Excel workbooks?  worksheets?  where is the SQL stored?

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@mahoneypat 

 

I want to load them into separate excel sheets in the same excel file.

It is currently stored in a text file.

 

Thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors