Forum Discussion
Update db schema en masse, SQL Server Connector
- 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
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
- Anonymous4 years agoNot applicable
Thank you BA_Pete !! I did not know that just copying from the query pane into a text editor would transfer the m code, and vice versa.
That might be a workable solution to make the best of this messy situation.
- Anonymous4 years agoNot applicable
Hi BA_Pete ,
I'm testing this out now, and it doesn't quite seem to work as I envisioned.
Copying multiple queries out into a text editor works fine, but Power Query doesn't seem to accept a plain-text paste back into the Query pane.- BA_Pete4 years agoSuper User
Hi Anonymous ,
Have you tried just clicking on the query pane then hitting Ctrl+V?
Also *might* work if you just paste the whole lot into a single new blank query. Something in my head is telling me that PQ is smart enough to split it all out into separate queries, but not able to test myself right now.
Pete
- Anonymous4 years agoNot applicable
Thanks BA_Pete , both good suggestions.
But I tried both and had no luck with either. PQ didn't respond to Ctrl+V in the Query Pane, and pasting all in a blank query just lead to a "Expression.SynaxError: Token Eof expected"