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
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"
Anonymous ,
That's a bummer. I was sure PQ did something smart when copying multiple queries back in.
I guess a lot of the heavy lifting has already been done, so maybe just need to take the pain on the final step and copy each segment from the text file back into blank queries.
I know there's a way to read M code directly from a text file by using Expression.Evaluate, but I can't imagine you want to be holding all your queries remotely from your PBIX in text files.
Pete
- Anonymous4 years agoNot applicable
Thanks for looking at it anyways, this has given me some good ideas!