Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
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.
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
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThe Power BI Data Visualization World Championships is back! It's time to submit your entry.
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 60 | |
| 49 | |
| 30 | |
| 25 | |
| 23 |
| User | Count |
|---|---|
| 132 | |
| 102 | |
| 59 | |
| 39 | |
| 31 |