SQL Compare 8

Switches used in the command line

This is a list of switches you can use with the SQL Compare command line.

Note that:

  • the first data source ( /db1, /b1, and so on ) is the source
  • the second data source ( /db2, /b2, and so on ) is the target
  • The command line syntax of previous versions of SQL Compare is considered deprecated, but continues to be supported.

    For example, in SQL Compare 7, the alias for /BackupSet1 was /bs1. In SQL Compare 8, the alias is now /bks1. You can continue to use /bs1 in SQL Compare 8, but a message is displayed informing you of the new alias.

Deprecated command line syntax will cease to be supported at a future release.

/activateSerial:<serialnumber>

Note: This switch is case sensitive.

Attempts to activate the application with the license key provided. An internet connection is required to activate the product.

If you run the switch without specifying a key, it will display the activation window.

You can license the command line with a SQL Compare Professional license or bundle such as the SQL Toolbelt; this will also license the GUI of those products. Alternatively you can license only the SQL Compare command line with an Automation license.

/Argfile:<argfile>

Runs a file containing an XML argument specification:

sqlcompare /Argfile:XMLFileName.xml

For more information, see: Using XML to specify command line arguments.

/Assertidentical

When /assertidentical is specified, SQL Compare will return an exit code of 0 if the objects being compared are identical. If they are not identical it will return exit code 79.

/Backup1:<filename1>;<filename2>;...;<filenameN>

Alias: /b1

Specifies the backup to be used as the source. You must add all of the files making up the backup set you want to compare:

sqlcompare /Backup1:D:\BACKUPS\WidgetStaging.bak /db2:WidgetStaging

To specify more than one backup file, the file names are separated using semicolons:

sqlcompare /Backup1:D:\BACKUPS\WidgetDev_Full.bak; D:\BACKUPS\WidgetDev_Diff.bak /db2:WidgetDev

For more information, see: Working with backups.

/Backup2:<filename1>;<filename2>;...;<filenameN>

Alias: /b2

Specifies the backup to be used as the target. You must add all of the files making up the backup set you want to compare:

sqlcompare /db1:WidgetStaging /Backup2:D:\BACKUPS\WidgetStaging.bak

/BackupPasswords1:<Password1>,<Password2>,...,<Password1N>

Alias: /bpsw1

Specifies the password for the source backup:

sqlcompare /Backup1:D:\BACKUPS\WidgetStaging.bak /BackupPasswords1:P@ssw0rd /db2:WidgetProduction

/BackupPasswords2:<Password1>,<Password2>,...,<Password1N>

Alias: /bpsw2

Specifies the password for the target backup:

sqlcompare /db1:WidgetStaging /Backup2:D:\BACKUPS\WidgetProduction.bak /BackupPassword2:P@ssw0rd

/BackupSet1:<backupSet>

Alias: /bks1

If you are comparing a backup set that contains multiple files, use the /BackupSet1 switch to specify the files which make up the source backup set, and use the /BackupSet2 switches to specify the files which make up the target:

sqlcompare /Backup1:"D:\MSSQL\BACKUP\WidgetDev.bak" /BackupSet1:"2008-09-23 Full Backup" /db2:WidgetLive

If the backup set switches are not specified, SQL Compare uses the latest backup set.

To specify more than one backup file, the file names are separated using semi-colons.

sqlcompare /Backup1:D:\BACKUPS\WidgetDev_Full.bak; "D:\BACKUPS\WidgetDev_Diff.bak" /db2:WidgetDevlopment

For encrypted backups that have been created using SQL Backup, use the /BackupPasswords1 and /BackupPasswords2 switches to specify the passwords; when there is more than one password, the passwords are separated using semi-colons.

sqlcompare /Backup1:D:\BACKUPS\WidgetDev.sqb /BackupPassword1:Pa$$w0rd /db2:WidgetLive

/BackupSet2:<backupSet>

Alias: /bks2

Specifies which backup set to use for the target backup:

sqlcompare /db1:WidgetProduction /BackupSet2:"2008-09-23 Full Backup"

/Database1:<database1>

Alias: /db1

Specifies a database to use as the source:

sqlcompare /Database1:WidgetStaging /Database2:WidgetProduction

/Database2:<database2>

Alias: /db2

Specifies a database to use as the target.

/deactivateSerial

Note: This switch is case sensitive.

Attempts to deactivate the application. An internet connection is required to deactivate the product.

/Exclude:<object type>:<regular expression>

Note: We recommend using filters instead of /Exclude. For more information, see Using filters.

Arguments:

  • Additional

only those objects that are not present in the source (eg /db1)

  • Missing

only those objects that are not present in the target (eg /db2)

  • Different

only those objects that are present in both data sources, but are different.

  • Identical

identical objects in the command line output and any generated reports.

  • User specified

objects you specify with a regular expression (eg /include:Table:WidgetPurchases)

To specify the list of objects to exclude, use the /exclude switch:

sqlcompare /db1:Customers1 /db2:Customers2 /exclude:table

/exclude:table specifies that you do not want to compare tables; you only want to compare other objects such as views, stored procedures, and so on.

To specify more than one object or object type for exclusion use multiple /exclude switches. For example, to exclude only tables and views:

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /exclude:table:WidgetReferences /exclude:view

Note that you cannot use /exclude with the /include and /project switches.

For a more detailed example using the /include and /exclude switches, see: Selecting tables with unrelated names.

/Filter

Alias: /ftr

Specifies a custom filter to select objects for synchronization.

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /sync

     /filter:MarketingViewsOnly.scpf

You can set up a filter to include or exclude objects based on their type, name, and owner (schema) name.

This is useful, for example, if you want to create complex selection rules without using regular expressions.

Note that:

  • filters are set up in the graphical user interface
  • filters are saved with the extension .scpf
  • /filter cannot be used with /Include or /Exclude
  • if you use /filter with /project, the filter you specify overrides any filter used in the project

For more information, see: Using filters.

/Force

Alias: /f

This forces the overwriting of any output files that already exist. If this switch is not used and a file of the same name already exists, the program will exit with the exit code indicating an IO error.

/Help

Alias: /?

Displays the list of switches in the command line with basic descriptions.

If /help is used with any switches except /verbose/html/out/force or /outputwidth then those extra switches will be ignored; the help message will be printed and the process will end with exit code 0.

/HTML

Outputs the help text as HTML. Must be used with the /help switch.

/IgnoreParserErrors

If SQL Compare encounters any high level errors when parsing a scripts folder, it will exit with an error code of 62.

Use /ignoreParserErrors to force SQL Compare to continue without exiting.

/Include:<object type>:<regular expression>

Note: We recommend using filters instead of /include. For more information, see Using filters.

Arguments:

  • Additional

only those objects that are not present in the source (eg /db1)

  • Missing

only those objects that are not present in the target (eg /db2)

  • Different

only those objects that are present in both data sources, but are different.

  • Identical

identical objects in the command line output and any generated reports.

  • User specified

objects you specify with a regular expression (eg /include:Table:WidgetPurchases)

  • StaticData

static data in a source-controlled database or a scripts folder

This switch is used to specify the list of objects to include. You can use an /include switch for each object that you want to compare. However, this can be unwieldy if there is a long list. Instead, you can use the pipe character ( | ) to separate the table names:

sqlcompare /db1:Customers1 /db2:Customers2 /include:table /include:table:\[Product\]^|Customer^|Order^|Invoice

For more detailed information on using the /include switch, see: Selecting tables with unrelated names.

/MakeScripts:<folder>

Alias: /mkscr

Creates a scripts folder from the data source.

sqlcompare /db1:WidgetStaging /makeScripts:"C:\Scripts Folders\Widget staging scripts"

If the folder already exists an error will occur. To merge scripts into an existing scripts folder, compare them with that folder and use the /synchronize switch:

sqlcompare /scr1:"C:\Scripts Folders\Widget dev scripts" /scr2:"C:\Scripts Folders\Widget staging scripts" /synchronize

For more information, see: Working with scripts folders.

/MakeSnapshot:<FileName>

Alias: /mksnap

Creates a snapshot from the data source.

sqlcompare /db1:WidgetStaging /makeSnapshot:"C:\Widget Snapshots\StagingSnapshot.snp"

If the file already exists an error will occur, unless you have also used the /force switch.

/Options:<option1>,<option2>,<option3>

Alias: /o

Applies the project configuration options used during comparison or synchronization:

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /options:Default,IgnoreWhiteSpace

For a detailed list of these options see: Options used in the command line.

/Out:<FileName>

Redirects console output to the specified file:

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /out:C:\output file

/OutputProject:<FileName>

Alias: /outpr

Writes the settings used for the comparison to the specified SQL Compare project file:

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /options:Default,IgnoreWhiteSpace /outputProject:"C:\WidgetProject.scp"

This also generates a SQL Compare project file. These files end with a .scp extension. If the file already exists an error will occur, unless you have also used the /force switch.

/OutputWidth:<columns>

Forces the width of console output.

This can be used to ensure that database object names etc are not truncated, and that SQL script lines are not wrapped or broken. This is particularly useful when redirecting output to a file as it allows you to overcome the limitations of the default console width of 80 characters.

/Password1:<password1>

Alias: /p1

The password for the source database.

You must also provide a username. If you do not specify a username and password combination, integrated security is used:

sqlcompare /db1:WidgetStaging /userName1:User1 /password1:P@ssw0rd /db2:WidgetProduction /userName2:User2 /password2:Pa$$w0rd

Note that this switch is only used if the source is a database. If the source is a backup, use /backupPasswords1

/Password2:<password2>

Alias: /p2

The password for the target database.

/Project

Alias: /pr

Uses a SQL Compare project (.scp) file for the comparison.

To use a project you have saved as "widgets.scp" from the command line:

sqlcompare /project:"C:\SQLCompare\Projects\Widgets.scp"
  • When you use a project, all objects that were selected for comparison when you saved the project are automatically included.
  • When you use the command line, your project option selections are ignored and the defaults are used. Use /options to specify any additional options you want to use with a command line project.
    For more information, see: Options used in the command line.
  • If you want to include or exclude objects from an existing project, you must modify your selection using the graphical user interface.
  • You cannot use the /include and /exclude switches with /project.

The /project switch is useful, for example, as you cannot specify a custom filter in the command line, and specifying complex object selections using a regular expression can be unwieldy.

For more information on using projects, and what a project contains, see: Working with projects.

/Report:<filename>

Alias: /r

Generates a report and writes it to the specified file.

The type of report is defined by the /reportType switch. If the file already exists an error will occur, unless you have used the /force switch:

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /report:"C:\reports\WidgetReport.html" /reportType:Simple

/ReportType:<reporttype>

Alias: /rt

Arguments:

  • XML

Simple XML report

  • Simple

Simple HTML report

  • Interactive

Interactive HTML report

  • Excel

Microsoft Excel spreadsheet

This switch defines the file format of the report produced by the /Report switch. The default setting is XML.

For example:

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /report:"C:\reports\WidgetReport.html" /reportType:Simple

For more information, see: Exporting the comparison results.

/Revision1:<revision1>

Alias: /r1

Specifies the source control revision of the source database. To specify a revision, the database must be linked to SQL Source Control.

To specify the lastest version, type: HEAD

The following example compares revision 3 of WidgetStaging with the latest revision of WidgetProduction:

sqlcompare /db1:WidgetStaging /revision1:3 /db2:WidgetProduction /revision2:HEAD

/Revision2:<revision2>

Alias: /r2

Specifies the source control revision of the target database. To specify a revision, the database must be linked to SQL Source Control.

/ScriptFile:<scriptfile>

Alias: /sf

Generates a SQL script to migrate the changes which can be executed at a later time. If the file already exists an error will occur, unless you use the /force switch:

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /scriptFile: "C:\Scripts Folder\WidgetSyncScript.sql"

/Scriptfile can be used when the target ( /db2, /scr2, /sn2 ) is a database, a snapshot, or a scripts folder.

If the target is a snapshot or a scripts folder, the generated script modifies a database with the schema represented by that snapshot or scripts folder.

/Scripts1:<folder>

Alias: /scr1

Specifies the scripts folder to use as the source:

sqlcompare /scripts1:"C:\Scripts Folder\WidgetStagingScript" /db2:WidgetProduction

/Scripts2:<folder>

Alias: /scr2

Specifies the scripts folder to use as the target.

/scriptsfolderxml:<scriptsfolderxml>

Alias: /sfx

Specifies a file containing the script folder location XML fragment.

/Server1:<server1>

Alias: /s1

Specifies the server on which the source (/db1:) datbase is located. If an explicit path is not specified, it defaults to Local.

sqlcompare /server1:Widget_Server\SQL2008 /db1:WidgetStaging /db2:WidgetProduction

/Server2:<server2>

Alias: /s2

Specifies the server on which the target (/db2:) database is located. If an explicit path is not specified, it defaults to Local.

/Snapshot1:<filename>

Alias: /sn1

Specifies the snapshot to use as the source:

sqlcompare /snapshot1:"C:\Snapshots\WidgetStagingSnapshot.snp" /db2:WidgetProduction

/Snapshot2:<filename>

Alias: /sn2

Specifies the snapshot to use as the target:

/Synchronize or /Synchronise

Alias: /sync

Synchronizes the databases after comparison.

The target (for example, /db2) is modified; the source (for example, /db2) is not modified:

sqlcompare /db1:WidgetStaging /db2:WidgetProduction /synchronize

/SyncScriptEncoding:<scriptencoding>

Alias: /senc

Arguments:

  • UTF8

UTF-8 encoding, without preamble

  • UTF8WithPreamble

UTF-8 encoding, with 3-byte preamble

  • Unicode

UTF-16 encoding

  • ASCII

ASCII encoding

Specifies the character encoding used when writing the SQL script file. The default is UTF8.

For example:

sqlcompare /db1:WidgetStaging /makeScripts: D:\Scripts Folder /syncScriptEncoding:ASCII

/TransactionIsolationLevel:<transactionIsolationLevel>

Alias: /til

Sets the Transaction Isolation Level to set in the SQL script.

/UserName1:<username1>

Alias: /u1

The username for the source database.

If no username is specified, integrated security is used.

sqlcompare /db1:WidgetStaging /userName1:User1 /password1:P@ssw0rd /db2:WidgetProduction /userName2:User2 /password2:Pa$$w0rd

/UserName2:<username2>

Alias: /u2

The username for the target database.

If no username is specified, integrated security is used.

 


Didn't find what you were looking for?