SAP Knowledge Base Article - Public

2584906 - How to display the SQL Query on the report in Crystal Reports?

Symptom

  • 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?
      
        
  • Note: Images and data in this SAP Knowledge Base Article is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.

Environment

  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016
  • SAP Crystal Reports 2020
       
  • SAP Crystal Reports for Enterprise 4.1
  • SAP Crystal Reports for Enterprise 4.2
  • SAP Crystal Reports for Enterprise 4.3

Reproducing the Issue

  1. In Crystal Reports, create a report off any data source.
  2. Add at least a table and a couple of database fields to the report.
  3. Add a record selection to the report.
  4. When refreshing the report, it sent to the database a SQL Query like:
     
        Select Client, Country, Region, City
        From Customer
        Where Country = 'USA' 
       
    How to display the SQL Query on the report?

Resolution

  • 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.
      
    1. Open the report in Crystal Reports.
       
    2. Under the menu "Database", select "Show SQL Query..."
       
    3. Copy the SQL Query dispalyed.
        
         Report - SQL Query.png
       
       
    4. Add a Text Object on the report where you want to display the SQL Query, and paste the SQL Query.
         
           
      Important Note:
          
      Depending on the report design, the above suggestion will not always reflect the SQL Query sent to the database by the report.
       
      For example:
         
      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.

Keywords

CR, SQLquery , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports 2013 ; SAP Crystal Reports 2016 ; SAP Crystal Reports 2020