ApexSQL Compare Command Line Interface (CLI) switches

Applies to
ApexSQL Compare

Summary
This article explains the ApexSQL Compare CLI switches, and their usage through the examples.

Description

Connection switches

/left_script File path of the left script, along with the corresponding file extension (*.sql, *.cs, *.py, *.vb, *.xml, etc.)
Alias: /ls
Format: /left_script:”LeftScript.sql”
/right_script File path of the right script, along with the corresponding file extension (*.sql, *.cs, *.py, *.vb, *.xml, etc.)
Alias: /rs
Format: /right_script:”RightScript.sql”
/server1 Specifies a server and instance name of the left SQL instance
Alias: /s1
Format: /server1:left_server_name
[\instance_name]
/server2 Specifies a server and instance name of the right SQL instance
Alias: /s2
Format: /server2:right_server_name
[\instance_name]
Quick tip icon

Quick tip:

If a server is not specified “(local)” instance is assumed

/database1 Specifies a name of the left database
Alias: /d1
Format: /database1:LeftDatabaseName
/database2 Specifies a name of the right database
Alias: /d2
Format: /database2:RightDatabaseName
/username1 Specifies the left login when using SQL Server authentication
Alias: /u1
Format: /user1:LeftLogin
Note: This switch must be used together with the
/password1 switch
/username2 Specifies the right login when using SQL Server authentication
Alias: /u2
Format: /user2:RightLogin
Note: This switch must be used together with the
/password2 switch
Quick tip icon

Quick tip:

If a user is not specified a trusted connection is assumed

/password1 Specifies the left login’s password when using SQL Server authentication
Alias: /p1
Format: /password1:leftpassword
Note: This switch must be used together with the
/username1 switch
/password2 Specifies the left login’s password when using SQL Server authentication
Alias: /p2
Format: /password2:rightpassword
Note: This switch must be used together with the
/username2 switch
/type1 Specifies the SQL object type for the left side database (table, view, procedure, etc.)
Alias: /t1
Format: /type1:table
Note: This switch must be used together with the /object1 switch
/type2 Specifies the SQL object type for the left side database (table, view, procedure, etc.)
Alias: /t2
Format: /type2:table
Note: This switch must be used together with the /object2 switch
/object1 Specifies the name of the left object (needs to be in format [schema].[name] or schema.name)
Alias: /o1
Format: /object1:Person.Address
Note: This switch must be used together with the /type1 switch
/object2 Specifies the name of the left object (needs to be in format [schema].[name] or schema.name)
Alias: /o2
Format: /object2:Person.Address
Note: This switch must be used together with the /type2 switch
/left_folder Folder path of the left folder used in the Folders comparison type
Alias: /lf
Format: /left_folder:”LeftFolder”
/right_folder Folder path of the left folder used in the Folders comparison type
Alias: /rf
Format: /right_folder:”RightFolder”

Specific switches

/project Specifies a project file, along with “.axcp” extension
Alias: /pr
Format: /project:”MyProject.axcp”
Quick tip icon

Quick tip:

If a project file is saved outside of the current directory, specify the path where it’s located

/output_type Output type of the comparison result:

  • html [h]

Alias: /ot
Format: /output_type:html

/output_name File path of the output comparison results, along with the corresponding file extension (*.html)
Alias: /on
Format: /output_name:”ComparisonResults.html”
/output_elements A set of output format options:

  • Author [a]
  • DateTime [dt]
  • Legal [l]
  • Default [dft] – none of the output format options is used by default

Alias: /oe
Format: /output_elements:[a|dt|l]
Note: These arguments can be combined
The Author and Legal values must be used together with the /author and /legal switches

/author Enter a name of the author for the comparison report
Alias: /auth
Format: /author:”John Doe”
Note: If the /author switch is specified, its dependent switch and value /output_elements:a needs to be provided
/legal Enter legal information for the comparison report
Alias: /leg
Format: /legal:”© ApexSQL LLC”
Note: If the legal switch is specified, its dependent switch and value /output_elements:1 needs to be provided
/separate_css A separate CSS file will be created next to the HTML file for additional editing
Alias: /sc

File comparison switches

/comparison_mode Comparison mode used for file comparison:

  • Character [c]
  • Line [l]
  • Block [b]
  • Default [dft] – The Line comparison mode is a default comparison mode

Alias: /co
Format: /comparison_mode:[c|l|b]
Note: These arguments can be combined

/ignore_scripting_
options
A set of the ignore options:

  • None [n]
  • Ansi [a]
  • Authorization [auth]
  • Collations [c]
  • Comments [com]
  • ConstraintNames [cn]
  • Filegroups [f]
  • Indexes [i]
  • LockEscalation [le]
  • Permissions [p]
  • WithEncryption [we]
  • Default [dft] – None of the ignore options is used by default

Alias: /iso
Format: /ignore_options:[a|auth|c|com|cn|f|i|le|p|we]
Note: These arguments can be combined

Folder comparison switches

/compare_hidden_
files
Includes hidden files in the folder comparison
Alias: /chf
/show_different_
only
Shows different files only
Alias: /sdo
/ignore_bigger_than Ignores files bigger than specified size
Alias: /ibt
Format: /ignore_bigger_than
/file_size_type Set the file size type for the files that will be ignored with the /ignore_bigger_than switch:

  • Byte
  • KB
  • MB
  • GB
  • TB
  • Default [dft] – MB is used as default size type

Alias: /fst
Format: /file_size_type:MB
Note: These arguments cannot be combined

/ignore_extension Ignores files with specified extensions (*.bak, *.exe, *.dll, etc.)
Alias: /ige
Format: /ignore_extension:”*.bak;*.exe;*.dll”

Merge and synchronize switches

/merge Creates a merge script from compared files
Alias: /m
/merge_path File path of a merge script, along with the corresponding file extension (*.sql, *.cs, *.py, *.vb, *.xml, etc.)
Alias: /mp
Format: /merge_path:“MergeScript.sql”
/sync_right Synchronizes all files from left to right folder
Alias: /sr
/sync_left Synchronizes all files from right to left folder
Alias: /sl
/backup_folder Backups folder that will be synchronized before the synchronization
Alias: /bf
/backup_path Folder path for the backup folder
Alias: /bp
Format: /backup_path:”BackupFolder”
Note: This switch must be used together with the /backup_folder switch

Learn more about additional switches from the article on this link.

Return codes

ApexSQL applications have two groups of return error codes:

  1. Common return error codes – learn more about these from here
  2. Specific return code – for ApexSQL Compare it’s the:

    101 – No differences detected – The compared scripts or folders are equal and the /rece switch is used

Examples

Note: All examples assume that the current directory is the application directory. If not, the full path to ApexSQLCompare.com must be specified.

Quick tip icon

Quick tip:

The “.com” extension is not necessary to run the application in the CLI

Compare two files to check if there are any differences:

ApexSQLCompare /ls:”LeftScript.sql” /rs:”RightScript.sql”

Compare two files to export differences into HTML report:

ApexSQLCompare /ls:”LeftScript.sql” /rs:”RightScript.sql” /ot:html /on:”ComparisonResults.html”

Compare SQL script against an object from a SQL Server database using SQL Server authentication:

ApexSQLCompare /ls:”LeftScript.sql” /s2:ServerName /u2:UserName /p2:P@$$M0rd /d2:DatabaseName /t2:ObjectType /o2:Schema.Name

Compare two files and create a merge script with default checked lines for merging:

ApexSQLCompare /ls:”LeftFile.xml” /rs:”RightFile.xml” /m
/mp:”MergeFile.xml”

Compare two files using the saved project file and create HTML comparison report:

ApexSQLCompare /pr:”MyProject.axcp” /ot:html /on:”ComparisonResults.html”

Compare two folders to check if there are any differences:

ApexSQLCompare /lf:”LeftFolder” /rs:”RightFolder”

Compare two folders to export differences into HTML report:

ApexSQLCompare /lf:”LeftFolder” /rs:”RightFolder” /ot:html
/on:”ComparisonResults.html”

Compare two folders and synchronize all files from left to right folder:

ApexSQLCompare /lf:”LeftFolder” /rs:”RightFolder” /sr

Compare two folders and synchronize all files from right to left folder and create a backup folder:

ApexSQLCompare /lf:”LeftFolder” /rs:”RightFolder” /sl /bf
/bp:”LeftFolderBackup”

Compare two folders to include hidden files, show different files only, ignore files with extensions: *.bak, *.exe, *.dll, and create HTML report:

ApexSQLCompare /lf:”LeftFolder” /rs:”RightFolder” /chf /sdo /ie:”*.bak;*.exe;*.dll” /ot:html /on:”ComparisonResults.html”