Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe 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.
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 @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
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsUser | Count |
---|---|
122 | |
69 | |
67 | |
58 | |
52 |
User | Count |
---|---|
189 | |
96 | |
67 | |
63 | |
53 |