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
mmwindel
New Member

Make report over different databases on sql server

Hi,

 

Say you have a sql server with several databases within, one database for each customer/client. These databases have the same tables, same structure etc. How would go about developing a report which extracts the same query from every databases and uses the data as one data source, knowing the number of databases might change periodically, new customers/customers leaving ?

 

I know this a large question, let me see if I can break it up:

  • How to get a list of every database-name on a sql server
  • How to loop over the different databases and run the same query on each of them
  • Add the results from each query together
  • How to do this dynamically, as the number of databases might change

I hope my questions are clear and consice, any help would be appreciated.

Thank you.

 

2 REPLIES 2
littlemojopuppy
Community Champion
Community Champion

First, I would wonder why you have a single database for each customer instead of one database with a field for customer to differentiate between them.

 

But...you should be able to access them individually using Power Query by using each database as a data source.  Add a field for customer to each table pulled from each database so that when you merge each query together you can still tell which customer the data applies to.  I don't believe that you can loop through them in Power Query, but someone who is stronger in that can offer guidance.

 

But again, your underlying is that you shouldn't be using separate databases for each customer...that is just creating problems for yourself.

amitchandak
Super User
Super User

@ImkeF , can you help on this

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.