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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
sp292610
New Member

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 @sp292610 ,

 

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
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.