Automate report creation from the command line

The /datareport command lets you create data reports from the command line. This is particularly useful when you need to generate reports repeatedly using the same report template.

To generate a report from the command line, first create a report template using Data Report Wizard. To specify parameter values from the command line, include the corresponding parameter names in a query in your report template.

Note

Parameter values specified directly in the command line override values defined in the report template.

Syntax

dbforgesql.com /datareport [/option_name1[:value | [parameter1:value parameter2:value ..]] /option_name2 ..]

Get command-line help

To view the list of switches available for /datareport, run the following command:

dbforgesql.com /datareport /?

The output displays all switches and their descriptions.

Command details

  • To run dbForge Studio CLI commands, open Command Prompt and navigate to the folder that contains dbforgesql.com. The default path to this executable depends on where dbForge Studio for SQL Server is installed. If you installed dbForge Studio:

    As a standalone tool

    C:\Program Files\Devart\dbForge Studio for SQL Server
    

    As part of the dbForge Edge bundle

    C:\Program Files\Devart\dbForge Edge\dbForge Studio for SQL Server
    
  • The /reportfile and /result switches are required to generate a report. All other switches are optional.

  • To specify the path to the .rdb file containing your report template, use the /reportfile switch.

dbforgesql.com /datareport /reportfile:<file_path> /result folder:<folder_path>
  • To save the report to a specific folder, provide the path to the folder.
dbforgesql.com /datareport /reportfile:<file_path> /result folder:<folder_path>
  • To send your report by email, provide the email address.
dbforgesql.com /datareport /reportfile:<file_path> /result email:<email>
  • To send your report to FTP, specify the FTP destination URL and authentication credentials.
dbforgesql.com /datareport /reportfile:<file_path> /format:<file_format> /result folder:<ftp_folder_url> ftplogin:<username> ftppassword:<your_password>
  • To specify the output format for the report, use the /format switch.
dbforgesql.com /datareport /reportfile:<file_path> /result folder:<folder_path> /format:<file_format> 
  • To provide values for the parameters defined in the .rdb report template query, use the /parameters switch.
dbforgesql.com /datareport /reportfile:<file_path> /format:HTML /parameters <param_name1>:<param_value1> <param_name2>:<param_value2> /result folder:<folder_path>

Create a report template

1. Open the Data Report Wizard in one of these ways:

  • On the menu bar, select Database > Report Designer.
  • On the Data Analysis tab of the Start Page, select Design New Report.

2. In the Data Report Wizard, configure the report settings.

3. If you want to specify values for report parameters from the command line, select Custom Query on the Choose a data connection page and include one or more parameters in the query.

The Choose a data connection page and the Create a new query page of the Data Report Wizard with a query entered.

In this example, @territory_name is the parameter name that must be specified from the command line. For more information, see Specify parameters for a report from the command line.

4. Save the report template as an .rdb file by selecting File > Save.

Configure email account settings

To send the generated report by email, configure the email account settings in the Options dialog.

1. On the menu bar, select Tools > Options.

2. In the Options dialog, navigate to Environment > SMTP.

3. Configure the following SMTP (Simple Mail Transfer Protocol) settings:

  • From address – Specify the email address that appears as the sender of the report email.

  • SMTP server – Specify the hostname or IP address of your SMTP mail server (for example, smtp.gmail.com).

  • Port – Specify the port number to connect to the SMTP server.

  • Timeout (seconds) – Specify the maximum time to wait for a response from the SMTP server.

  • Enable SSL – Select the checkbox to enable encrypted communication with the SMTP server.

  • Requires authentication – Select the checkbox if the SMTP server requires user authentication.

  • Name – Specify the username you use to authenticate with the SMTP server (the email address).

  • Password – Specify the password or application-specific password for SMTP authentication.

Configure SMTP settings in the Options dialog

4. Click OK.

Examples

Example 1: Generate a report and save it to a folder

This command generates a report based on the salesorders-report.rdb template and saves the result in HTML format to the specified folder.

dbforgesql.com /datareport /reportfile:"D:\Reports\Templates\salesorders-report.rdb" /format:HTML /result folder:"D:\Reports\Generated reports\"

Example 2: Specify parameters for filtering report data from the command line

This command generates an HTML report filtered by the Northwest sales territory using the territory_name parameter.

dbforgesql.com /datareport /reportfile:"D:\Reports\Templates\salesorders-by-territory.rdb" /parameters territory_name:"Northwest" /format:HTML /result folder:"D:\Reports\Generated reports" /resultfilename:"salesorders-northwest"

For more information, see Specify parameters for a report from the command line.

Example 3: Save a report locally and send it by email

You can generate a report and distribute it via multiple channels. This command saves the generated report to a folder on your computer and sends it by email simultaneously.

Note

To send reports by email, configure SMTP settings. For more information, see Configure email account settings.

dbforgesql.com /datareport /reportfile:"D:\Reports\Templates\salesorders-report.rdb" /format:PDF /result folder:"D:\Reports\Generated reports" email:"[email protected]"

Example 4: Upload a report to an FTP server

This command generates a PDF report based on the salesorders-report.rdb template and sends it to the specified FTP server using the provided authentication credentials.

dbforgesql.com /datareport /reportfile:"D:\Reports\Templates\salesorders-report.rdb" /format:PDF /result folder:"ftp://ftp.example.com/reports/" ftplogin:"ftpuser" ftppassword:"P@ssw0rd123"