Forum Discussion
Multiple Databases with the same Data Source
- 7 years ago
Hi Anonymous ,
I got your point and tried to set the query table dynamically:
1. In query editor pane, New source>SQL server> "Servername" (Keep database name as empty) > IM mode> select one table > Ok, then delete the Navigation step. you'll get the list of database in the first column.
2. Right click the column > Add as new query
3. Then create the parameter based on the query, everytime you refresh the data source, the list will be updated, we can fetch the data in different DB by switching parameter value.
But the problem is One parameter works for One database, and fetch one table under it:(DB is the parameter name)
let Source = Sql.Databases("MININT-8GMT4UN\SQLEXPRESS"), DB = Source{[Name= DB]}[Data] in DBYou can select the specific table under the database, and final one is Table1
Then add another new query to get the table 2 :
Then we can use the M code to append Table1 with Table2 as new table, (Notes Table1 and Table2 are dynamically changing when we switch the parameter).
let Source = Table.Combine({Table_1, Table}) in SourcePlease let me know if it works for you.
Thanks again v-diye-msft ,
I already tried the parameter approach, but it doesn't seem to answer my specific need.
Let's say that today I got 2 DB's, so my flow is:
- define the DB's in the list
- set first DB - fetch data
- set second DB - fetch data
- append the two into one table
Tomorrow, I'll have 10 DB's, should I manually redo all the steps? how is the parameter helps me?
My idea was a defining a loop that will do the steps dynamicly:
for each db in list
- query table
- append
end loop
I just can't seem to understand how to implement it.
Regards,
Eliran.
Hi Anonymous ,
I got your point and tried to set the query table dynamically:
1. In query editor pane, New source>SQL server> "Servername" (Keep database name as empty) > IM mode> select one table > Ok, then delete the Navigation step. you'll get the list of database in the first column.
2. Right click the column > Add as new query
3. Then create the parameter based on the query, everytime you refresh the data source, the list will be updated, we can fetch the data in different DB by switching parameter value.
But the problem is One parameter works for One database, and fetch one table under it:(DB is the parameter name)
let
Source = Sql.Databases("MININT-8GMT4UN\SQLEXPRESS"),
DB = Source{[Name= DB]}[Data]
in
DB
You can select the specific table under the database, and final one is Table1
Then add another new query to get the table 2 :
Then we can use the M code to append Table1 with Table2 as new table, (Notes Table1 and Table2 are dynamically changing when we switch the parameter).
let
Source = Table.Combine({Table_1, Table})
in
Source
Please let me know if it works for you.