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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Automation of Schema Creation in Power BI

Can we read the table names from SQL query and then pull those tables from DB2 to Power BI to automate the process of schema creation?

Is it possible to get the table names from a sql query(sql script in notepad) and then search for those tables in DB2 database and pull those tables to Power BI?

 

Please guide on this.

1 REPLY 1
MFelix
Super User
Super User

Hi @Anonymous ,

 

To what I can understand you have the SQL query stored in a file and you want to run that query dinamically on your PBI correct?

 

Try the following code:

let
    SQLCode ={ Text.FromBinary(File.Contents("C:\Folderpathlocation\SELECT.SQL"))}{0},
    Source = Sql.Database("SQLServer", "DatabaseName", [Query=SQLCode])
in
    Source

The SQLCode line gets the information from the CSV extract the SQL query and runs it on the last part of the Source step [Query=SQLCode]


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.