SQL Data Compare 15

Switches used in the command line

This page provides a list of the switches you can use with the SQL Data Compare command line.

  • the first data source ( /db1, /b1, and so on ) is the source
  • the second data source ( /db2, /b2, and so on ) is the target

/AbortOnWarnings:<warning level>

Alias: /aow

Specifies that SQL Data Compare won't run a deployment if there are any serious deployment warnings. If you don't specify this switch, SQL Data Compare will ignore warnings and run the deployment.

Arguments

NoneDon't abort on warnings
MediumAbort on medium or high warnings
HighAbort on high warnings

The default is None. If you use this switch and there are deployment warnings, exit code 61 is displayed.

/activateSerial:<serial number>

  • This switch is case sensitive.
  • An internet connection is required to activate SQL Data Compare from the command line.
    For information about how to activate manually without an internet connection, see Activating

You can specify a SQL Data Compare Professional serial number, or a serial number for bundle such as the SQL Toolbelt Essentials:

sqldatacompare /activateSerial:123-456-789012-ABCD

If you're using the SQL Data Compare command line on a server, you need to use the /allUser switch in addition to /activeSerial. Learn more about Using the command line on a service account in Windows.

/allUsers

Activates SQL Data Compare command line for all users (including Windows service accounts). For more information see: Using the command line on a service account in Windows

/activedirectory1

Alias: /ad1

Uses Azure active directory authentication with the first database. If a username and password combination is specified, then Active Directory password authentication will be used.

/activedirectory2

Alias: /ad2

Uses Azure active directory authentication with the second database. If a username and password combination is specified, then Active Directory password authentication will be used.

/AllowIdenticalDatabases

This switch is deprecated. Instead use /Include:Identical

/Include:Identical suppresses the exit code if the two data sources are identical. If /Include:Identical is not set, SQL Data Compare returns the error code 63.

/Argfile:<argfile>

Runs a file containing an XML argument specification:

sqldatacompare /Argfile:XMLFileName.xml

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

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

Alias: /b1

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

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

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

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

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

Alias: /b2

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

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

Contents

/BackupCompression:<compression level>

Alias: /bc

Compresses a backup using one of three compression levels.

Arguments

1Compression level 1 is the fastest compression, but results in larger backup files. On average, the backup process is 10% to 20% faster than when compression level 2 is used, and 20% to 33% fewer CPU cycles are used. Backup files are usually 5% to 9% larger than those produced by compression level 2. However, if a database contains frequently repeated values, compression level 1 can produce backup files that are smaller than if you used compression level 2 or 3. For example, this may occur for a database that contains the results of Microsoft SQL Profiler trace sessions.
2This compression level uses the zlib compression algorithm, and is a variation of compression level 3.
On average, the backup process is 15% to 25% faster than when compression level 3 is used, and 12% to 14% fewer CPU cycles are used. Backup files are usually 4% to 6% larger.
3Compression level 3 uses the zlib compression algorithm. This compression level generates the smallest backup files in most cases, but it uses the most CPU cycles and takes the longest to complete.

You can only compress Redgate (SQL Backup Pro) backups.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup /backupcompression:3

/BackupEncryption

Alias: /be

Encrypts a backup using 128-bit encryption.

  • You can only encrypt Redgate (SQL Backup Pro) backups.
  • If you encrypt a backup, you must specify a password using /BackupPassword.
sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup /backupencryption /backuppassword:P@ssw0rd

/BackupFile:<file name>

Alias: /bf

The file name to use when creating a backup.

For Redgate backups, use the file extension .sqb. For native SQL Server backups, use .bak.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup /backupfile:WidgetProductionBackup.sqb

/BackupFolder:<folder path>

Alias: /bd

The folder to use for storing backups.

If you don't use this switch, backups are stored in the folder specified in the SQL Backup options for the SQL Server instance. If you're not using SQL Backup, or no backup file locations have been set up, backups are stored in the SQL Server instance's default backup folder, for example:

C:\Program Files\Microsoft SQL Server\MSSQL11.SQL2012\MSSQL\Backup

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup /backupfolder:C:\Backups

/BackupNumberOfThreads:<number of threads>

Alias: /bth

Uses multiple threads to speed up the backup process. SQL Backup can use up to a maximum of 32 threads.

We recommend you start with one thread fewer than the number of processors. For example, if you are using four processors, start with three threads.

You can only use multiple threads with Redgate (SQL Backup Pro) backups.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup /backupnumberofthreads:2

/BackupOverwriteExisting

Alias: /boe

Overwrites existing backup files of the same name when creating a backup.

/BackupType:<backup type>

Alias: /bt

The type of backup to perform.

Arguments

FullFull backup
DifferentialDifferential backup

The default is Full.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup /backuptype:differential

/BackupPassword:<password>

Alias: /bp

The password to use when encrypting a backup.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup /backupencryption /backuppassword:P@ssw0rd

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

Alias: /bpsw1

Specifies the password for the first backup:

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

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

Alias: /bpsw2

Specifies the password for the second backup:

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

/BackupProvider:<backup format>

Alias: /bpr

The format of the backup file to create when backing up the target database.

Arguments

Native

Native SQL Server backup (.bak)

SQB

SQL Backup Pro backup (.sqb)

The default is SQB.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup /backupprovider:native

/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 first backup set, and use the /BackupSet2 switches to specify the files which make up the second:

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

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

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

sqldatacompare /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's more than one password, the passwords are separated using semicolons.

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

/BackupSet2:<backupset>

Alias: /bks2

Specifies which backup set to use for the second backup:

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

/CaseSensitive

This switch is deprecated. Instead use /Options:CaseSensitiveObjectDefinition

/Columns

This switch is deprecated. Instead use /IncludeColumns and /ExcludeColumns

/ComparisonKeys:<table or view name as regular expression>:<index name>

Alias: /ck

Specifies a unique index to be used to identify rows for comparison.

The name of the table or view is specified using a regular expression - you don't have to specify fully-qualified names. We recommended you use a regular expression which matches only one table or view:

sqldatacompare /Database1:WidgetStaging /Database2:WidgetProduction
     /IncludeColumns:[WidgetPrices]:Price
     /ComparisonKeys:[WidgetPrices]:PK_WidgetPrices
  • /ComparisonKeys must be used with the /IncludeColumns switch
  • with /ComparisonKeys you can only specify an index as the comparison key, no other columns can be specified

To specify a comparison key that's not an index, use the GUI to set up and save a project with the settings you require. You can then use that project from the command line with the /Project switch.

For more information on using the GUI to set comparison keys, see Selecting the comparison key, under Selecting tables and views.

/Database1:<database1>

Alias: /db1

Specifies a database to use as the source:

sqldatacompare /Database1:WidgetStaging /Database2:WidgetProduction

/Database2:<database2>

Alias: /db2

Specifies a database to use as the source:

sqldatacompare /Database1:WidgetStaging /Database2:WidgetProduction

/empty2

Use this as the target data source to make a script that creates the source database data. You can use this script with SQL Packager 8.

For example, you want to package the schema and data of a database, WidgetStaging, so that when the package is run it will create a copy of the database schema and data. You've already made a script of the schema using SQL Compare, and now you want to make a script of the data.

sqldatacompare /Server1:MyServer\SQL2014 /Database1:WidgetStaging /empty2 /ScriptFile:"C:\Scripts\WidgetStagingData.sql"

If you need to package a database upgrade and you've added a new table containing new data, use the MissingFrom2AsInclude option.

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

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:

sqldatacompare /db1:Customers1 /db2:Customers2 /Exclude:table

/Exclude:table specifies that you don't want to compare tables; you only want to compare other objects such as views, stored procedures, etc.

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

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction
     /Exclude:table:WidgetReferences /Exclude:view

You can't use /Exclude with the /Include and /Project switches.

For a more detailed example of how to use the /include and /exclude switches, see Example: selecting tables with unrelated names.

/ExcludeColumns:<table or view name>:<regular expression>

Alias: /ec

Specifies which columns within a table or view are excluded from deployment.

Table or view names are matched using a regular expression so you don't have to specify fully-qualified names. However, it doesn't usually make sense to supply a regular expression that matches more than one table or view. Multiple column names should be specified as a comma-separated list.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction
     /ExcludeColumns:WidgetReferences:WidgetName

/ExcludeColumns takes precedence over /IncludeColumns

/Export:<directory>

Alias: /e

Exports the comparison results to the specified directory as a .csv file.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction
     /Export:C:\WidgetResults

Note that the file created is always called Summary.csv

You specify the directory in which the file is created.

/ExportIdenticalTables

This switch is deprecated. Instead use /Include:Identical

/Force

Alias: /f

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

/IgnoreParserErrors

If SQL Data 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 Data Compare to continue without exiting.

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

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)

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

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

/Include:Identical suppresses the exit code if the two data sources are identical. If /Include:Identical is not set, SQL Data Compare returns the error code 63.

For a more detailed example of how to use the /include switch, see: Example: selecting tables with unrelated names

/IncludeAdditional

This switch is deprecated. Instead use /Include:Additional

/IncludeColumns

Alias: /ic

Specifies which columns within a table or view are included in the deployment.

Table or view names are matched using a regular expression so you don't have to specify fully-qualified names. However, it doesn't usually make sense to supply a regular expression that matches more than one table or view. Specify multiple column names as a comma-separated list.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction
     /IncludeColumns:WidgetReferences:WidgetName

/ExcludeColumns takes precedence over /IncludeColumns


/LogLevel:<level>

Alias: /log

Creates a log file with a specified minimum log level.

Log files collect information about the application while you're using it. These files are useful to us if you've encountered a problem. For more information, see Logging and log files.

Arguments

None

Disables logging

Error

Reports serious and fatal errors

Warning

Reports warning and error messages

Verbose

Reports all messages in the log file

The default is None.

For example:

sqldatacompare /db1:WidgetStaging /makeScripts:"D:\Scripts Folder" /logLevel:Verbose
You must use /logLevel each time you want a log file to be created.

/MakeBackup

Backs up the target database using Redgate SQL Backup Pro or SQL Server native.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /sync /makebackup

/MakeScripts:<folder>

Alias: /mkscr

Creates a scripts folder from the first (source) data source.

sqldatacompare /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:

sqldatacompare /scr1:"C:\Scripts Folders\Widget dev scripts"
     /scr2:"C:\Scripts Folders\Widget staging scripts" /Synchronize

/MaxTransactionSizeMB:<size>

Alias: /mts

The maximum size of transactions/batches in the deployment script in megabytes.

Use this switch to split the deployment script into transactions/batches which are a maximum size. Use the DontUseTransactions option to switch between transactions and batches.

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

Alias: /o

Applies the project configuration options used during comparison or deployment:


sqldatacompare /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:

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /Out:C:\output file

/OutputProject:<FileName>

Alias: /outpr

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

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction
     /Options:Default,IgnoreWhiteSpace /OutputProject:"C:\WidgetProject.sdc"

This also generates a SQL Data Compare project file. These files end with a .sdc extension. If the file already exists an error will occur, unless you've 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 first database (source).

You must also provide a username. If you don't specify a username and password combination, integrated security is used:

sqldatacompare /db1:WidgetStaging /UserName1:User1 /Password1:P@ssw0rd
     /db2:WidgetProduction /UserName2:User2 /Password2:Pa$$w0rd

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 second database.

/Project

Alias: /pr

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

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

sqldatacompare /Project:"C:\SQLCompare\Projects\Widgets.sdc"
  • When you use a project, all objects will be selected rather than only those that were selected for comparison when you saved the project.
  • You can't use the /include and /exclude switches with /project unfortunately.
  • 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.

/Revision1:<revision>

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 latest version, type: HEAD

Specifying a revision other than HEAD is only supported with TFS, SVN and Vault. If you're using another source control system, we recommend checking the revision out to a local folder and using the /Scripts1 switch.

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

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

/Revision2:<revision>

Alias: /r2

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

/SyncScriptEncoding

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:

sqldatacompare /db1:WidgetStaging /MakeScripts: D:\Scripts Folder
     /SyncScriptEncoding:ASCII

/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:

sqldatacompare /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 script folder to use as the first data source:

sqldatacompare /Scripts1:"C:\Scripts Folder\WidgetStagingScript"
     /db2:WidgetProduction

/Scripts2:<folder>

Alias: /scr2

Specifies the script folder to use as the second data source.

/ScriptsFolderXML:<file path>

Alias: /sfx

The path to a text file containing XML that describes the location of a source control repository.


  1. In the SQL Source Control Setup tab for a source-controlled database, click on the Show link next to Under the hood 
  2. Copy the XML fragment from the SQL Compare XML fragment block to the clipboard by clicking the Copy button:
     
  3. Create a new text file and paste the XML fragment into it.
  4. Save the file.

/Server1:<server1>

Alias: /s1

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

sqldatacompare /Server1:Widget_Server\SQL2008 /db1:WidgetStaging
     /db2:WidgetProduction

A non-default port can be specified, as well as connecting with encrypt=true and trustservercertificate=true (when set to true, SSL is used to encrypt the channel when bypassing walking the certificate chain to validate trust.)

sqldatacompare /Server1:"Widget_Server\SQL2008,<port>;encrypt=true;trustservercertificate=true" 
	/db1:WidgetStaging /db2:WidgetProduction

/Server2:<server2>

Alias: /s2

Specifies the server on which the second (/db2:) data source is located. If an explicit path isn't specified, it defaults to Local.

/ShowWarnings

Alias: /warn

Displays any warnings that apply to the deployment.

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction /showWarnings

/Sourcecontrol1

Specifies a folder of source-controlled scripts to use as the source.

If you use this switch, you must also specify /scriptsfolderxml.

 If you want to use a specific revision of the database, you can also specify /revision1

sqlcompare /sourcecontrol1 /revision1:100 /sfx:"C:\Files\scripts.txt" /db2:WidgetProduction

/Sourcecontrol2

Specifies a folder of source-controlled scripts to use as the target.

If you use this switch, you must also specify /scriptsfolderxml.

 If you want to use a specific revision of the database, you can also specify /revision2.

sqlcompare db1:WidgetStaging /sourcecontrol2 /revision2:100 /sfx:"C:\Files\scripts.txt"

/Synchronize

Alias: /sync

Deploys the data after comparison.

The target (for example, /db2) is modified; the source (for example, /db1) isn't modified:

sqldatacompare /db1:WidgetStaging /db2:WidgetProduction
     /Synchronize

/UserName1:<username1>

Alias: /u1

The username for the first database.

If no username is specified, integrated security is used.

sqldatacompare /db1:WidgetStaging /UserName1:User1 /Password1:P@ssw0rd
     /db2:WidgetProduction /UserName2:User2 /Password2:Pa$$w0rd

/UserName2:<username2>

Alias: /u2

The username for the second database.

If no username is specified, integrated security is used.


Didn't find what you were looking for?