General Usage

Console Application Name

Note: ApexSQL Diff console examples are used in this help topic as they are consistent across most ApexSQL applications.

To use ApexSQL Software via the commandline interface you may simple enter in the product name. For example apexsqldiff. 

You may also explicitly call the console application with it's explicit filename [productname].com

Calling to [productname].exe is reserved for the GUI application and will initiate this instead of initiate the console application. If arguments are included it will throw a warning dialog similar to this

Format of Switches

  1. Switches are case insensitive, i.e. /S: = /s:.
  2. Switches are preceded with one forward slash (/), i.e. /db:pubs.
  3. Switches are followed with a colon (:), i.e. /db:pubs.
  4. There are two types of all switches - abbreviated/alias (1-3 chars) and Full - with full name of switch. i.e. /p and /project
  5. Default values for omitted parameters are used in most cases. Default values are specified in the following format in /help switch ("<default>" if omitted), i.e. ("(local)" if omitted) as illustrated in the following example.

Passing Values

  1. Values should be passed to switches in the following format (see examples). 

apexsqldiff.com /switch:value

apexsqldiff.com /switch:"value with spaces"

  1. Use Double quotes for values that contain spaces.

  2. Do not put a space between the colon and the value

Structure of Switches

  1. Switches can be placed in arbitrary order.
  2. Switches and parameters are delimited with a white space from each other.

Connection Switches

  1. If server is not specified "(local)" is assumed.
  2. If user is not specified trusted connection is assumed.
  3. If no server specified output "No server was specified so assuming "(local)" server".
  4. If no security specified output "No security parameter was specified so assuming trusted connection".

File IO

  1. All applications have a /force switch which will override existing file of same name. Otherwise this should produce an error.
  2. All input (profiles, projects) and output (scripts, reports) files are stored and taken from/into the current directory unless explicit output directory has been specified as a part of file name/path.
  3. All application/error logs/dumps are written to the current directory.

Special Keys

  1. It is possible to abort execution with Ctrl+C and Ctrl+Break key combinations.

Output Redirection

To spool output to file vs the console you can use either > (for file output) or >> (for file append)

For Example :

Return Codes

All ApexSQL applications should have support for common return codes. Individual application support of these codes may vary until implementation has been completed in all applications

0 – Success

1 – General error

2 – Illegal argument combination/duplication. Some arguments may not appear in command line at the same time. Some arguments may not be duplicated in command line. Some required arguments are missed in command line.

3 – Invalid value. The value supplied for an argument is invalid.

4 – IO error. Some error occurred during IO operation. Also returned if an application attempts to write to existent file without a user having specified a /force option.

5 – Insufficient permissions. Action cannot be completed because a user doesn't have required permissions.

To obtain a return code note the following example

@C:\ApexSQL\ApexSQLDiff\ApexSQLDiff.com /s1:ABN\TEST2001 /s2:ABN\TEST2000 /d1:pubs /d2:pubs70 /v /f

@echo ApexSQLDiff exit code is %errorlevel%

Common Switches

Help Switch

All console enabled ApexSQL applications support the Help Switch which can be called using either switch /help or /?

The following is an example of Help output:

Verbose Switch

All console supported applications support the Verbose switch which will spool out meaningful messages, warnings, etc during processing. With this switch specified application outputs full operation information to a console. Otherwise it operates in silent mode without any output produced (except some specific switches like /help and /test specified). The following is an example of the generation of a synchronization script with verbose switch on.

Test Switch

All console supported applications support the Test switch which is a useful feature to validate your CLI input prior to processing. This will simply parse switch input and if successful, will list all successfully parsed switches. Application error handling takes precedence over the Test output - so if there is a incorrect switch value then the standard error messages will be returned.