"Basic" SQL editor required for ODBC connection to DB2

%3CLINGO-SUB%20id%3D%22lingo-sub-1603623%22%20slang%3D%22en-US%22%3E%22Basic%22%20SQL%20editor%20required%20for%20ODBC%20connection%20to%20DB2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1603623%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20Office%20365%20I%20now%20have%20to%20use%20the%20Data%20tab%20to%20establish%20an%20ODBC%20connection%20to%20a%20DB2%20for%20z%2FOS%20database%2C%26nbsp%3Bselecting%20%22From%20other%20sources%22%2C%20%22From%20ODBC%22%20and%20then%20connecting%20to%20the%20DB2%20database.%3C%2FP%3E%3CP%3EI%20can%20enter%20an%20SQL%20query%20under%20%22Advanced%20options%22%20and%20then%20Load%20the%20returned%20data%20into%20a%20worksheet.%3C%2FP%3E%3CP%3EHaving%20done%20this%2C%20is%20there%20an%20%22easy%22%20way%20to%20edit%20the%20SQL%20query%20without%20having%20to%20try%20and%20use%20the%20horrendous%20Advanced%20Editor%20in%20Power%20Query%20Editor%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20older%20versions%20of%20Excel%20I%20used%20to%20be%20able%20to%20very%20quickly%20edit%20the%20query%20by%20right-clicking%20the%20data%20and%20selecting%20Table%2C%20External%20Data%20Properties%20and%20then%20Definition%2C%20or%20the%20Table%2C%20Edit%20Query%20option.%20I%20am%20despairing%20of%20ever%20using%20Excel%20again%2C%20as%20this%20new%20interface%20is%20horrible.%3C%2FP%3E%3CP%3EAll%20I%20want%20is%20a%20simple%20text%20box%20where%20I%20can%20enter%20%2F%20edit%20the%20SQL%20just%20like%20I%20used%20to%20be%20able%20to%20%3CLI-EMOJI%20id%3D%22lia_disappointed-face%22%20title%3D%22%3Adisappointed_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ESteve%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1605968%22%20slang%3D%22en-US%22%3ERe%3A%20%22Basic%22%20SQL%20editor%20required%20for%20ODBC%20connection%20to%20DB2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1605968%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F766849%22%20target%3D%22_blank%22%3E%40SJLamb%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPower%20Query%20Advanced%20Editor%20is%20designed%20for%20M-script%2C%20not%20for%20SQL%20query%2C%20and%20works%20quite%20good%20with%20it.%20If%20you%20skip%20adding%20SQL%20query%20at%20the%20first%20step%20and%20just%20connect%20to%20database%2C%20you%20may%20select%20tables%2C%20views%2C%20fields%2C%20etc%20in%20Power%20Query%20Editor%20without%20using%20Advanced%20Editor%2C%20keeping%20the%20latest%20for%20more%20complex%20cases%20-%20but%20that%20will%20be%20M-script.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1606415%22%20slang%3D%22en-US%22%3ERe%3A%20%22Basic%22%20SQL%20editor%20required%20for%20ODBC%20connection%20to%20DB2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1606415%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Sergei%2C%3C%2FP%3E%3CP%3EMy%20DB2%20source%20tables%20contain%20(literally)%20billions%20of%20rows%20of%20performance%20data%20and%20so%20I%20need%20to%20use%20the%20SQL%20to%20perform%20filtering%20and%20return%20just%20the%20data%20I%20want%2C%20especially%20if%20I%20want%20to%20join%20multiple%20tables.%20I%20then%20want%20to%20be%20able%20to%20re-use%20the%20query%20so%20that%20I%20can%20change%20things%20easily%20e.g.%20time%20periods.%20I%26nbsp%3B%3CEM%3Eused%3C%2FEM%3E%20to%20be%20able%20to%20do%20this%20in%20older%20versions%20of%20Excel%2C%20but%20can't%20in%20Office%20365.%3CBR%20%2F%3EIf%20I%20enter%20the%20SQL%20when%20I%20establish%20the%20connection%2C%20the%20data%20gets%20brought%20back%20in%20a%20%22preview%22%20mode%20and%20then%20the%20query%20gets%20run%20a%20second%20time%20when%20I%20chose%20the%20option%20to%20Load%20the%20data%20-%20seems%20a%20bit%20of%20an%20overhead%20to%20do%20things%20in%20this%20way.%3C%2FP%3E%3CP%3EIf%20I%20skip%20adding%20the%20SQL%20query%2C%20I%20get%20presented%20with%20a%20list%20of%20tables%20%2F%20views%20and%20then%20don't%20seem%20to%20be%20able%20to%20enter%20an%20SQL%20query%20to%20perform%20the%20filtering%20I%20need.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1606793%22%20slang%3D%22en-US%22%3ERe%3A%20%22Basic%22%20SQL%20editor%20required%20for%20ODBC%20connection%20to%20DB2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1606793%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F766849%22%20target%3D%22_blank%22%3E%40SJLamb%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPower%20Query%20supports%20folding%20mechanism.%20For%20example%2C%20you%20query%20the%20table%20with%20few%20dozens%20millions%20of%20rows%2C%20on%20second%20step%20remove%20unused%20columns%2C%20on%20next%20step%20filter%20what%20needed.%20If%20use%20correctly%20PQ%20generates%20SQL%20query%20in%20background%20(it%20could%20be%20seen%20from%20right%20click%20menu%20on%20steps).%20Thus%20it%20doesn't%20load%20millions%20of%20rows%20on%20first%20step%20and%20perform%20other%20operations%20one%20by%20one%20on%20them%2C%20It%20loads%20final%20result.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERelationships%20in%20many%20cases%20could%20be%20recognized%26nbsp%3B%20and%20related%20records%20are%20returned.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20course%2C%20if%20you%20do%20not%20rely%20on%20above%20mechanisms%20you%20may%20use%20native%20SQL%20query%2C%20with%20that%20folding%20won't%20work.%20One%20or%20another.%20And%20again%2C%20if%20old%20query%20interface%20was%20designed%20to%20generate%20SQL%20query%2C%20Power%20Query%20use%20another%20mechanisms.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20in%20File-Options-%26gt%3BData%20you%20may%20activate%20legacy%20interfaces%20(they%20are%20disabled%20by%20default)%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorSergei%20Baklan_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EAfter%20activation%20you%20may%20use%20them%20from%20this%20menu%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20464px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214192i8D33592B0B79B3FA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1606795%22%20slang%3D%22en-US%22%3ERe%3A%20%22Basic%22%20SQL%20editor%20required%20for%20ODBC%20connection%20to%20DB2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1606795%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20screenshot%20disappeared%20from%20previous%20post%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20623px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214193i8071C0CE6AF1319B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1607573%22%20slang%3D%22en-US%22%3ERe%3A%20%22Basic%22%20SQL%20editor%20required%20for%20ODBC%20connection%20to%20DB2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1607573%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3EHi%20Sergei%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20there's%20probably%20something%20wrong%20with%20my%20setup%2C%20as%20I%20can't%20use%20the%20legacy%20Data%20Connection%20Wizard%20option%20in%20365.%20If%20I%20select%20this%20and%20chose%20my%20DB2%20database%2C%20Excel%20just%20disappears%20-%20no%20error%20messages%20on%20the%20screen%20at%20all.%20I%20don't%20know%20why%20%2F%20how%20this%20is%20different%20from%20establishing%20an%20ODBC%20connection%20from%20Other%20Sources.%20I'll%20see%20about%20raising%20a%20fault%20with%20our%20internal%20support%20team.%3C%2FP%3E%3CP%3EWe've%20recently%20migrated%20from%20Win%207%20to%20Win%2010%20and%20I've%20had%20to%20update%20my%20IBM%20ODBC%20drivers%20to%20a%20new%20version%20as%20well.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESome%20of%20my%20source%20tables%20have%20about%20400%20columns%20and%20I%20might%20only%20want%2020%20columns%20in%20my%20data%2C%20so%20it's%20much%20easier%20if%20I%20can%20use%20an%20existing%20SQL%20query%20rather%20than%20having%20to%20remove%20380%20columns%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20help%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1612378%22%20slang%3D%22en-US%22%3ERe%3A%20%22Basic%22%20SQL%20editor%20required%20for%20ODBC%20connection%20to%20DB2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1612378%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F766849%22%20target%3D%22_blank%22%3E%40SJLamb%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESorry%2C%20I%20had%20no%20experience%20with%20DB2%2C%20have%20no%20idea%20what%20could%20be%20an%20issue%20with%20the%20driver.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOf%20course%2C%20if%20you%20are%20more%20comfortable%20with%20SQL%20query%2C%20use%20it.%20I%20also%20use%20native%20queries%20from%20time%20to%20time%2C%20it%20depends%20on%20concrete%20project.%20The%20only%20my%20point%20PQ%20editor%20is%20not%20designed%20to%20work%20with%20SQL%20from%20user%20interface.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJust%20in%20case%2C%20for%20your%20sample%20it's%20not%20necessary%20to%20remove%20380%20columns%2C%20it's%20enough%20to%20select%2020.%20That's%20easy%20enough%20from%20user%20interface%20only%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20467px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214723i5D9F48EEC43B147D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

In Office 365 I now have to use the Data tab to establish an ODBC connection to a DB2 for z/OS database, selecting "From other sources", "From ODBC" and then connecting to the DB2 database.

I can enter an SQL query under "Advanced options" and then Load the returned data into a worksheet.

Having done this, is there an "easy" way to edit the SQL query without having to try and use the horrendous Advanced Editor in Power Query Editor?

 

In older versions of Excel I used to be able to very quickly edit the query by right-clicking the data and selecting Table, External Data Properties and then Definition, or the Table, Edit Query option. I am despairing of ever using Excel again, as this new interface is horrible.

All I want is a simple text box where I can enter / edit the SQL just like I used to be able to

 

Regards,

Steve

6 Replies

@SJLamb 

Power Query Advanced Editor is designed for M-script, not for SQL query, and works quite good with it. If you skip adding SQL query at the first step and just connect to database, you may select tables, views, fields, etc in Power Query Editor without using Advanced Editor, keeping the latest for more complex cases - but that will be M-script.

@Sergei Baklan 

Hi Sergei,

My DB2 source tables contain (literally) billions of rows of performance data and so I need to use the SQL to perform filtering and return just the data I want, especially if I want to join multiple tables. I then want to be able to re-use the query so that I can change things easily e.g. time periods. I used to be able to do this in older versions of Excel, but can't in Office 365.
If I enter the SQL when I establish the connection, the data gets brought back in a "preview" mode and then the query gets run a second time when I chose the option to Load the data - seems a bit of an overhead to do things in this way.

If I skip adding the SQL query, I get presented with a list of tables / views and then don't seem to be able to enter an SQL query to perform the filtering I need.

 

 

@SJLamb 

Power Query supports folding mechanism. For example, you query the table with few dozens millions of rows, on second step remove unused columns, on next step filter what needed. If use correctly PQ generates SQL query in background (it could be seen from right click menu on steps). Thus it doesn't load millions of rows on first step and perform other operations one by one on them, It loads final result.

 

Relationships in many cases could be recognized  and related records are returned. 

 

If course, if you do not rely on above mechanisms you may use native SQL query, with that folding won't work. One or another. And again, if old query interface was designed to generate SQL query, Power Query use another mechanisms. 

 

However, in File-Options->Data you may activate legacy interfaces (they are disabled by default)

 

After activation you may use them from this menu

image.png

@Sergei Baklan 

One screenshot disappeared from previous post:

image.png

@Sergei Baklan 
Hi Sergei,

 

I think there's probably something wrong with my setup, as I can't use the legacy Data Connection Wizard option in 365. If I select this and chose my DB2 database, Excel just disappears - no error messages on the screen at all. I don't know why / how this is different from establishing an ODBC connection from Other Sources. I'll see about raising a fault with our internal support team.

We've recently migrated from Win 7 to Win 10 and I've had to update my IBM ODBC drivers to a new version as well.

 

Some of my source tables have about 400 columns and I might only want 20 columns in my data, so it's much easier if I can use an existing SQL query rather than having to remove 380 columns

 

Thanks for your help

@SJLamb 

Sorry, I had no experience with DB2, have no idea what could be an issue with the driver.

 

Of course, if you are more comfortable with SQL query, use it. I also use native queries from time to time, it depends on concrete project. The only my point PQ editor is not designed to work with SQL from user interface.

 

Just in case, for your sample it's not necessary to remove 380 columns, it's enough to select 20. That's easy enough from user interface only

image.png