Symptom
- SQL Query does not match the Filters added on the report.
- Change made in the Record Selection Formula, are not reflected in the the SQL Query generated for the report in Crystal Reports.
- Why does this behavior occur and how to resolve it?
Environment
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
- SAP Crystal Reports 2020
Reproducing the Issue
- In Crystal Reports, open a report.
- Update the Record Selection Formula.
- Under the menu "Database", select "Show SQL Query..."
- Notice the SQL Query does not reflect the update made in the Record Selection Formula.
Cause
- Under normal conditions, when adding a Record Selection Formula to a report, a WHERE clause is added to the SQL Query generated, representing the filtering criteria in the Record Selection Formula. However, if a report was originally created in Crystal Reports 8.5 and below, and the SQL Query had been manually modified ( This was an option in older versions of Crystal Reports ), then the SQL Query will not change. This is to ensure the customized SQL Query is maintained.
- If the report has been created in an older version of Crystal Reports 8.5 and below, and the SQL Query has been modified manually, then a 'Reset' button will appear when viewing the SQL Query in Crystal Reports.
Resolution
- To let Crystal Reports generate the SQL Query for old reports where the SQL Query was manually udpdated, click the "Reset" button, in the "Show SQL Query" window.
- In Crystal Reports, open the report.
- Under the menu "Database", select "Show SQL Query"
- If the SQL Query was manually modified in Crystal Reports 8.5 or below, a reset button will appear at the bottom of the window. Click on the "Reset" button.
Keywords
CR , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem
Product
SAP Crystal Reports 2013 ; SAP Crystal Reports 2016 ; SAP Crystal Reports 2020