- How to show the SQL Query on the report?
- Can we print on the report, the SQL Query used by the report?
- In Crystal Reports, how to display on the report the SQL Query used by the report?
SAP Crystal Reports 2008
- SAP Crystal Reports 2011
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
- SAP Crystal Reports for Enterprise 4.0
- SAP Crystal Reports for Enterprise 4.1
- SAP Crystal Reports for Enterprise 4.2
Reproducing the Issue
In Crystal Reports, create a report off any data source.
- Add at least a table and a couple of database fields to the report.
- Add a record selection to the report.
- When refreshing the report, it sent to the database a SQL Query like:
Select Client, Country, Region, City
Where Country = 'USA'
How to display the SQL Query on the report?
There is no option in Crystal Reports that can output, on the report, the SQL Query used by the report.
- A suggestion will be to manually copy in a Text Object the SQL Query used by the report.
- Open the report in Crystal Reports.
- Under the menu "Database", select "Show SQL Query..."
- Copy the SQL Query dispalyed.
- Add a Text Object on the report where you want to display the SQL Query, and paste the SQL Query.
Depending on the report design, the above suggestion will not always reflect the SQL Query sent to the database by the report.
If the report uses parameters, the SQL Query will change dynamically with the parameter values inserted.
Another example will be if the Record Selection used condition that depends on the parameter values, the WHERE clause could be different.
The above is only a suggestion that can give an idea of the SQL Query used by the report, but is not a way to actually display the SQL Query used by the report 100% of the time, as Crystal Reports does not have an option to do so.
CR, SQLquery , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To
Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016