Edit SQL in Power Query - excel-2010

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!

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.

Here's an illustration that complements the accepted answer.

Related

Is there any way to get the syntax of an SQL statement when using SQLPlus?

I have an exam using SQLPlus and sometimes I don't remember the exact syntax of SQL statements, so I was wondering if there is any way to get some nice inline help from inside SQLPlus.
For instance, say I forgot how to use INSERT INTO, and I want some reminder like this:
INSERT INTO table-name (column-names)
VALUES (values)
Is this possible?
I tried HELP command but none of that seems to suits my needs.
I Googled it with no success.
No. SQL is a standardized language (at least ANSI SQL) and SQLPlus "just" uses that syntax, so it's not covered by internal help. Internal help lists only SQLPlus specific commands (ex. SET, CONNECT, SPOOL).
It is possible to workaround that in some way, but very limited. You can call dbms_metadata.get_ddl function for some existing object. Some of those DDLs could have statements you are intrested in. For example - you'd like to see select statement - then you could call dbms_metadata.get_ddl for some existing view:
select dbms_metadata.get_ddl('VIEW', 'USER_TABLES', 'SYS')
from dual;
Be aware - it works only for Oracle 11G and lower, in the newest one SYS objects are not accessible in that way (I'm not sure about Oracle 12.1).
The more interesting are tiggers, procedures, functions, and packages. You cannot use dbms_metadata to get DDLs of packages owned by SYS, but maybe you can connect to some sample schemas like HR (Human Resources), AD (Academic), SH (Sales History).
In HR schema there is stored procedure ADD_JOB_HISTORY, which has inside insert statement, so it looks like that:
select dbms_metadata.get_ddl('PROCEDURE', 'ADD_JOB_HISTORY')
from dual;
CREATE OR REPLACE EDITIONABLE PROCEDURE "HR"."ADD_JOB_HISTORY"
( p_emp_id job_history.employee_id%type
, p_start_date job_history.start_date%type
, p_end_date job_history.end_date%type
, p_job_id job_history.job_id%type
, p_department_id job_history.department_id%type
)
IS
BEGIN
INSERT INTO job_history (employee_id, start_date, end_date,
job_id, department_id)
VALUES(p_emp_id, p_start_date, p_end_date, p_job_id, p_department_id);
END add_job_history;
There are better ways and better tools to achieve your goal - see below.
Are you allowed to use SQL Developer instead of SQLPlus? SQL Developer has nice feature to drag-and-drop table icon into worksheet, then you will be nicely prompted to choose what kind of example statement you are looking for (SELECT, INSERT, UPDATE etc.) - after choosing one you will get sample statement.
But the best way is just open in browser Database SQL Language Reference:
https://docs.oracle.com/database/121/SQLRF/toc.htm

How do I print query results in DataGrip?

Is there a way to print the results of a query in DataGrip? I can print the query (not very useful) but when I select the result pane the print option in the File menu is grayed out.
Thanks.
follow these steps :
open view from the toolbar
open tool windows
select database changes
then you see a new tab in the console where you can monitor every changes you made (example :select * from table)

FireDAC - Show SQL after Macro Expantion

I am trying to use Macros in FireDAC to Preprocess my SQL Queries. I have a TADQuery object on a Data Module with the SQL set to something like:
Select * from MyTable
join OtherTable on MyTable.Key = OtherTable.Key
&Where
Then in my code I do this:
WhereClause = 'stuff based on my form';
Query.MacroByName('Where').AsRaw := WhereClause;
Query.Open;
This has worked great for complicated queries because it lets me make sure my fields and join conditions are correct using the SQL Property editor.
My problem is when the SQL statements ends up invalid because of my where clause. Is there any way to see the SQL after pre-processing that is going to be executed? Right now I am catching the FireDac errors and showing the SQL that is on EADDBEngineException object. However that is still showing my original SQL with the macros. If I can't get to it after the error happens is there anyway to force the Macro replacement to take place so I can look at the SQL in the debugger to help me see what is wrong.
If it matters I am connecting to a MS Access database with the goal of moving to SQL Server in the near future.
Apart from using Text property, to monitor what SQL is actually going to the database engine, consider using the "FDMonitor" FireDAC utility. According to the DokWiki pages (below):
drop a TFDMoniRemoteClientLink component on your form,
Set its Tracing property to True,
Add the MonitorBy=Xxx connection definition parameter to your existing FDConnection component. You can do this in the IDE object inspector, by selecting your FDConnection component, expanding the Params property, and setting MonitorBy to mbRemote.
Note that the TFDMoniXxxxClientLink should come before TFDConnection in the data module or form creation order, so adjust this by right clicking on the form or data module, then Creation Order, and moving the TFDMoni.. component above the FDConnection.
Also, it's helpful in the options of the TFDMoniXxxxClientLink, to disable most of the events being recorded, otherwise all the data returned is also shown in the FireDAC monitor. Expand the EventKinds property, and turn all the event kinds off, except for perhaps ekConnConnect, ekConnPrepare, and ekCmdExecute.
Then open the FireDAC Monitor from the IDE, (Tools > FireDAC Monitor). Start your app only once the monitor is running. Double click on a trace event (in the Trace Output tab), and you will see the actual SQL sent to the database in the bottom pane.
It also seems likely that adding the EventType of ekConnPrepare as mentioned above, would show you when the query's Prepare is called, but I haven't played enough with it say for sure.
Please see the following pages on the DocWiki for more information:
Overview: FDMonitor
How to: Tracing and Monitoring (FireDAC)
Other FireDAC utilities: Utilities (FireDAC)
(Just to remove this question from list of unanswered questions)
From comments:
Well, I've roughly checked what's happening there and I'm still not
sure if calling Prepare (which is useless for you as I get) is the
minimal requirement to trigger that preprocessing. Though, the
preprocessed SQL, the one which is sent to the DBMS you can access
through the Text property (quite uncommon name for such property). – TLama Feb
21 '14 at 8:18

How to export all Issues and its contents (Full content) to excel in JIRA?

Here I can able to download only the fields / I can get the contents of only one particular issues to word.
JIRA : Using Latest version.
Logged in as Administrator.
I searched Google but could'nt find.
Go to Issues and make a filter that returns all the issues you want
In the top right corner, there is a Views menu item. Open it.
Select the Excel (all fields) option to export all issues to Excel
#user1747116 you can use the method described by Whim but you do not get all of the information out of an issue.
You do have a couple of options:
If you are versed in XML you can go to System->Import / Export Section -> Backup and it does a full backup of your JIRA instance in XML as described in this help post.
You can use the method described by Whim of simply going to the issues list and clicking on the 'export function', but ALSO before doing that using one of the add-ons that allows you to export comments as well. Plug-ins specifically mentioned in this help article are "All Comments", "JIRA Utilities", and "Last Comment".
Write a Crystal Report formatted in a way to export into Excel. We have done this to make the information both accessible to those not versed in SQL. We have in particular done this for
You write an SQL Query and go directly at the database, and saving to CSV. Note in JIRA 4 to 6 the schema changed and we had to redo several of our queries so keep this in mind. But this is one to get you started in JIRA 6. Note time log is in ([worklog] and File Attachments are in ([fileattachment]) and comments are in ([jiraaction]). Each of these tend to have multiple entries per issue so you will need to do further joins to get them all into the same query. This is also useful know how if you are doing it in a Crystal Report and then exporting to excel.
SELECT TOP 1000 _JI.ID
,_JI.pkey
,_JI.PROJECT
,_PRJ.pname
,_JI.REPORTER
,_JI.ASSIGNEE
,_JI.issuetype
,_IT.pname
,_JI.SUMMARY
,_JI.DESCRIPTION
,_JI.ENVIRONMENT
,_JI.PRIORITY
,_PRI.pname
,_JI.RESOLUTION
,_RES.pname
,_JI.issuestatus
,_IS.Pname
,_JI.CREATED
,_JI.UPDATED
,_JI.DUEDATE
,_JI.RESOLUTIONDATE
,_JI.VOTES
,_JI.WATCHES
,_JI.TIMEORIGINALESTIMATE
,_JI.TIMEESTIMATE
,_JI.TIMESPENT
,_JI.WORKFLOW_ID
,_JI.SECURITY
,_JI.FIXFOR
,_JI.COMPONENT
,_JI.issuenum
,_JI.CREATOR
FROM jiraissue _JI (NOLOCK)
LEFT JOIN PROJECT _PRJ ON _JI.Project = _PRJ.ID
LEFT JOIN ISSUESTATUS _IS ON _JI.issuestatus = _IS.ID
LEFT JOIN ISSUETYPE _IT ON _JI.issuetype = _IT.ID
LEFT JOIN PRIORITY _PRI ON _JI.Priority = _PRI.ID
LEFT JOIN RESOLUTION _RES ON _JI.Resolution = _RES.ID
Note: You could get rid of the redundant fields, but I left both in so you can see where they came from. You can also put a where clause for a single issue ID or limit the outputs to a particular project. The top 1000 only displays the first 1000 results. Remove that if you are comfortable with it returning everything. (We tens of thousands in our db so I put that in there).
Exporting all details to Excel using the built-in export feature is simply impossible. Excel export will not export you the comments, the attachment, change history, etc. As other answers mention the Excel output produced by JIRA is in fact an HTML file, which works in many situations, but doesn't if you need precise representation of data.
Our company built a commercial add-on called the Better Excel Plugin, which generates native Excel exports (in XLSX format) from JIRA data.
It is powerful alternative to the built-in feature, with major advantages and awesome customization. It really supports Excel analysis functionality, including formulas, charts, pivot tables- and pivot charts.
This was my solution.
I downloaded the file like this:
"Issues" > "Search for Issues"
"Export" button > "Excel (HTML, All Fields)"
After downloading the file, Excel (Microsoft Office Professional Plus 2013) was not opening the download Jira.xls file for me.
I worked around that by doing the following:
Change the ".xls" to ".html"
Open the new "Jira.html" file in Chrome
Highlight/Select the table contents of the exported Jira Issues
Copy and then paste into a new excel file
The Better Excel add-on is great (we use it) but it cannot do attachments (AFAIK). Another add-on, JExcel Pro, can.

Delphi Search Edit Component

I need a delphi component for Delphi 2007 win32 that have features like Google search text box.
** While User writing search key it should fill/refresh the list with values, and user can select one of them.
**User can go up and down list and can select one of them.
**List should contain codes and text pair, so user can select text and I can get code for database operations.
(Google can highlight the search text in List but I think it is not possible with Delphi 2007, so it is not expected.)
I tried Dev Express TcxMRUEdit, however it doesn't meet my needs
Since you have DevExpress, why don't you try the cxLookupComboBox in lsEditMode and with ImmediateDropDown = True?
Check out woll2woll components. The TLookupcombobox has done this since Delphi 3 (or earlier). This is not spam, I just use the library.
http://www.woll2woll.com/
I also had the same problem and unfortunately didn't find a suitable component. I was also inspired from google.
So it turned out to be easier for me to "simulate a component" by using an editbox and a grid placed under it. As the user types something in the editbox the query refreshes and the proper resulst are shown in the grid. I have many columns in the grid, the query results try to match all the fields (so if I type 'po', the query will return all records where any field is like 'po%'). I also added a delay of 500ms after the user types to avoid to run too many unnecessary queries (another aproach could be to kill the thread as the user strikes a new key, if the query is run in a thread).
In this way I obtained the required functionality, even if without higlighting the search text, anyway my users are delighted by this.
In every place I am using this "component" I am attaching a query at runtime so it can be used in many different forms.
I somehow was also inspired by the skype UI: when you display the lsit of contacts you can type something and the contacts will be filtered accordingly (skype uses an editbox + grid/listbox).

Resources