SAP Knowledge Base Article - Public

2541233 - How to display the database name on the report in Crystal Reports?

Symptom

  • How to display the database the report is based off?
  • Is there a special function in Crystal Reports that will display the database name?
  • How to print on the report, the name of the database the report is using in Crystal Reports?

Environment

  • SAP Crystal Reports 2008
  • SAP Crystal Reports 2011
  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016

Resolution

  • There is no function, or special fields in Crystal Reports that will display the name of the database the report is based off.
         
  • A potential suggestion, will be to contact your database administrator, or look in the database documentation, and verify if there is a specific SQL function that can be used for your database to retreive the database name. If there is, and you have the necessary rights on the database, it might be possible to add the specific SQL Function of your database in a SQL Expression Field. Which you can then add on your report to display the database name.  
        
    For example:
       
    For MS SQL Server, the function: DB_NAME() returns the name of the Database the user is connecting to. To add the database name on the report for MS SQL Server:
       
    1. In Crystal Reports, open the report based off a MS SQL Server database, on which you want to display the database name.
         
    2. In the Field Explorer pane, right click on "SQL Expression Field", and select "New..."
         
    3. Type a name for the SQL Expression Field, and click "OK"
          
    4. In the SQL Expression Field window, type: DB_NAME()
        
    5. Save and close the SQL Expression Field.
        
    6. Add the SQL Expression Field on the report to display the database name.

Keywords

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

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016