Symptom
- How to switch from a Table to a custom SQL Query?
- How can you set the database location for a report from using a Table, to using a Command Object, in Crystal Reports?
Environment
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
- SAP Crystal Reports 2020
Resolution
- To switch a report from using a Table, to using a Command Object, perform a Set Datasource location:
-
In Crystal Reports, open your report.
-
Under the menu "Database", select "Set Datasource Location..."
-
In "Set Datasource Location", under "Replace With", create a connection to the data source.
-
Still in the section "Replace With", select under you data source connection: "Add Command"
-
At the top, under "Current Data Source", select your Table.
-
On the right side, click on "Update".
-
It the window "Add Command To Report", enter the SQL Query for your report.
- Click "OK"
If your SQL Query returns all the same database fields, then your report now is connecting to the same data source, but it is sending the custom SQL Query you have written. If the database fields name are different, you will have a mapping window that will prompt you to map the database fields.
- Back to the window "Set Datasource Location", click "Close"
- Save your report.
Keywords
ADD COMMAND OBJECT SET LOCATION SQL QUERY DATABASE EXPERT REPOSITORY Crystal Reports Set location Command object Repository , c2012566 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To