Forum Discussion

TungNguyen_19's avatar
TungNguyen_19
Helper III
3 years ago
Solved

How to use only 1 parameter to switch different database connections rather than 2?

Hello everyone,

Based on many related helpful posts changing connections by using 2 parameters (just like this one ) but I faced to this task when I have theses Azure SQL databases with different URL and db-name:

NameStageServer URL
devDevelopmentdev.database.windows.net
uatTestuat.database.windows.net
prodProductionprod.database.windows.net

How to use only 1 parameter to changing datasource which corresponds to each stage of the development lifecycle?

Many thanks to you guys

  • v-jingzhang's avatar
    v-jingzhang
    3 years ago

    Hi TungNguyen_19 

     

    When you connect to Azure SQL databases, Power Query uses Sql.Database function. It requires server and database as two separate parameters. So it seems not possible to use only one parameter to switch the data source. 

    Sql.Database(server as text, database as text, optional options as nullable record) as table

     

    If you use Odbc.DataSource, it may be possible to use only one parameter as it only requires connectionString. I haven't tested this yet. However ODBC connector only supports Import mode and the query performance is not as well as the SQL Server database connector. 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.

5 Replies

    • TungNguyen_19's avatar
      TungNguyen_19
      Helper III

      Hi pratyashasamal 

      This is not the solution for my problem, I mean yes we can use parameter but in my problem we have separate different servers, different tables and I want to switch between them by only 1 parameter (that is the Stage parameter which ties pair server and table for each stage as I described in the table above). This is the idea and I don't know how to do it?

      Thanks 

      • v-jingzhang's avatar
        v-jingzhang
        Community Support

        Hi TungNguyen_19 

         

        When you connect to Azure SQL databases, Power Query uses Sql.Database function. It requires server and database as two separate parameters. So it seems not possible to use only one parameter to switch the data source. 

        Sql.Database(server as text, database as text, optional options as nullable record) as table

         

        If you use Odbc.DataSource, it may be possible to use only one parameter as it only requires connectionString. I haven't tested this yet. However ODBC connector only supports Import mode and the query performance is not as well as the SQL Server database connector. 

         

        Best Regards,
        Community Support Team _ Jing
        If this post helps, please Accept it as Solution to help other members find it.