Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Update db schema en masse, SQL Server Connector

In an existing .pbix file which contains many SQL Server connections, I can adapt to changes in server name or database name (e.g. tables I'm connected to are moved between servers or databases) quit...
  • BA_Pete's avatar
    4 years ago

    Hi Anonymous ,

     

    A couple of ideas:

     

    1) To retrofit:

    - Select all queries in Power Query that you want to change schema, copy, paste into your text editor of choice.

    - In text editor, Find & Replace 'Schema="dbo"' with 'Schema="newSchema"'.

    - Delete all selected queries from PQ.

    - Select all in text editor and paste into PQ query pane.

     

    2) To manage in future:

    - In each new PBIX, create a query called 'schema' that is just '="dbo"'.

    - For each new table you import that is likely to change schema, change 'Schema="dbo"' to 'Schema=schema'.

    - You can now change the schema in all queries if required by changing the value in your new schema query.

     

    Pete