Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit SQL in Power Query

Tags:

When I import data from Sql Server in Power Query, I can paste a query to be executed against the database. But later when I want to edit this query in Workbook Queries > Edit > Advanced Editor, I get something like this:

let     Source = Sql.Database("server", "database", [Query="select#(lf)#(tab)*#(lf)from dbo.SomeView va#(lf)join dbo.SomeTable rm#(lf)#(tab)on rm.CatId=va.CatId#(lf)where 1=1#(lf)#(tab)and Month between 1501 and 1510#(lf)#(tab)and rm.Id in (1,2,3)"]) in     Source 

Please note that I'm using *, but with explicit column names this would look even worse.

I'd like to be able to see the query in a readable form, then copy it, execute in Management Studio, change something and paste back to Power Query. I know I could be using views as a source, or not using newlines and indentation, but that's not my point.

Any ideas on how to edit SQL in "normal" form? Or maybe I'm missing some hidden option.

EDIT: In case I'm not the only person in the world having problems finding this option, it's in:

Power Query > Launch Editor > View > Query Settings > Applied Steps > Source > Gear icon

Thanks Alejandro!

like image 993
AdamL Avatar asked Nov 12 '15 15:11

AdamL


1 Answers

If you click on the gear icon next to Source in the Query Settings pane you'll get a dialog with the SQL query in a readable form.

like image 132
Alejandro Lopez-Lago - MSFT Avatar answered Oct 13 '22 19:10

Alejandro Lopez-Lago - MSFT