Automate code formatting from the command line

Last modified: March 28, 2025

dbForge SQL Complete supports a command-line interface, which means you can automate code formatting in SQL Complete using the command line.

Format code from the command line

1. Run the Command Line in Windows 11:

From the Windows taskbar

  • Right-click the taskbar at the bottom of the screen and then select Run or click Start or press the Windows key on your keyboard to open the Start menu.
  • Type cmd or Command Prompt in the search bar.
  • Select the Command Prompt app from the search results to open it.

Using shortcut keys

  • Press the Windows + R keys to show the Run command window.
  • In the window that opens, type cmd and press Enter.

2. To access the dbForge SQL Complete functionality from the command line, navigate to the sqlcomplete.com file, located in the installation folder of the tool. The default installation folder is C:\Program Files (x86)\Devart\dbForge SQL Complete.

cd "C:\Program Files (x86)\Devart\dbForge SQL Complete"

3. To format the code, execute the /formatsql command by replacing the arguments with your actual data. The command formats SQL files with the specified profile:

sqlcomplete.com /formatsql /sourcefile:"D:\NoFormat.sql" /outputfile:"D:\Format.sql"

where:

  • "D:\NoFormat.sql" is a path to the source SQL file to be formatted.
  • "D:\Format.sql" is a path to an output file where the formatting results of the source file will be saved.

Get help

To get quick help on the arguments available in the command line, type the following:

sqlcomplete.com /?

Get help

To get detailed information about each command-line operation, execute the following command and specify the required option value sqlcomplete.com /option_name /?. For example, sqlcomplete.com /formatsql /?.

Additionally, you can watch this video to learn how to format SQL script files from the command line and how to automate the process using PowerShell.

Also, if you want to know how to involve dbForge SQL Complete in the Database DevOps process, watch this video.