Forum Discussion

Raul's avatar
Raul
Post Patron
8 years ago
Solved

Filter table names in a connection to a SQL Server database

Hello everyone.

I have a SQL Server database that contains more than 20,000 tables. I need to connect from Power BI Desktop to that database but I want to be able to filter the selection of the necessary tables for those starting with a certain prefix, for example, those starting with CUST *.
How can I specify this initial filter so that I can subsequently select the tables I need without having to load all the tables of the database before in the Navigator screen?

Thanks a lot!!!

  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi Raul,

     

    Please refer to below steps to filter the tables which stored in database.


    Steps:

    1. Connect to a database.

     

     

    2. Add a filter on 'Name' column and modify the filter formula to use 'Text.StartsWith' function.(For your scenario, you should use "CUST " as keyword to filter.)

     

    Full query:

    let
        Source = Sql.Databases("xxxxx"),
        #"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name],"D"))
    in
        #"Filtered Rows"

     

    BTW, please not connect too many table at one time. Large amount of tables may affect the performance and system resources.

     

    Regards,

    Xiaoxin Sheng

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Raul,

     

    Please refer to below steps to filter the tables which stored in database.


    Steps:

    1. Connect to a database.

     

     

    2. Add a filter on 'Name' column and modify the filter formula to use 'Text.StartsWith' function.(For your scenario, you should use "CUST " as keyword to filter.)

     

    Full query:

    let
        Source = Sql.Databases("xxxxx"),
        #"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name],"D"))
    in
        #"Filtered Rows"

     

    BTW, please not connect too many table at one time. Large amount of tables may affect the performance and system resources.

     

    Regards,

    Xiaoxin Sheng