Run SQL scripts from the command line

You can use the command-line interface to automate script execution in dbForge Studio for SQL Server.

Note

The command-line interface is available only in certain editions of dbForge Studio for SQL Server. For more information, see the Editions page.

1. Open the Command Prompt.

2. Type the path to the dbforgesql.com executable, which is located in the dbForge Studio for SQL Server installation folder, and press Space.

"C:\Program Files\Devart\dbForge Studio for SQL Server\dbforgesql.com"

Note

The executable path depends on the installation type. If dbForge Studio is installed as part of the dbForge Edge bundle, change the path accordingly:

cd "C:\Program Files\Devart\dbForge Edge\dbForge Studio for SQL Server"

3. Run the /execute command, followed by the required arguments.

Example command:

"C:\Program Files\Devart\dbForge Studio for SQL Server\dbforgesql.com" /execute /connection:"Data Source=DBMSSQL\MSSQL2012;Integrated Security=False;User ID=yourusername" /inputfile:"script.sql" /password:yourpassword /quiet

Arguments:

/execute – Runs the command.

/connection:"<connection_string>" – Specifies the target server connection.

/inputfile:"<file_path>" – Specifies the .sql or .zip script to run.

/password:<password> – (Optional) Overrides the password in the connection string.

/quiet – (Optional) Runs without displaying the Command Prompt window (useful in batch files).

4. Press ENTER.

Tip

To view syntax help for /execute, run: dbforgesql.com /execute /?

Use an argument file

You can store all arguments in a text file and reference it with /argfile.

Argument file contents (myarg.txt):

/execute
/connection:"Data Source=DBMSSQL\MSSQL2012;Integrated Security=False;User ID=yourusername"
/inputfile:"script.sql"

Command:

dbforgesql.com /argfile:myarg.txt

Command-line arguments

Select corresponding command line switches to perform the required operations:

Argument Action and Usage
/connection Specifies a connection string. Usage:
/connection:<connection_string>
/database Specifies the database for script execution. Any database specified in the script is ignored. This does not affect fully qualified object names.
/inputfile Specifies an .sql or .zip file containing the script to execute.
/password Specifies the server password and overrides the one in the connection string. Usage:
/password:<yourpassword>
/encoding Specifies the encoding for opening and executing the script. Usage:
/encoding:<encoding>