SQL Compare 15

Using the command line on Linux

SQL Compare Command Line can now be used on Linux, and is available through Docker Hub.

To access the Linux command line directly, grab the latest from our download site.

Differences from Windows

  • The backslash '\' is an escape character in bash.  You should therefore specify the server as /server1:Widget_Server\\SQL2008 when using the Linux commandline.
  • The filesystem in a container is isolated from the rest of the system.  You should use --mount to pass directories through to SQL Compare, for example when working with scripts folders and project files.
  • The container is also separate from your host machine in terms of network addresses.  You should use the name or IP address of your host machine instead of localhost when connecting to local SQL instances.
  • You should ensure you run docker commands as a member of the docker group (or alternatively as root).
  • You will need to use a personal access token and associated email address and pass these on each invocation. View our documentation on personal access tokens in CLIs to get started. 

  • Active Directory authentication is not supported on Linux.
  • Static data may work, but is not currently well tested on Linux.


Example commands to run SQL Compare through Docker on Linux

To compare a live database to an empty target

docker run --rm --interactive --tty \
    redgate/sqlcompare \
 	/token:"<personal-access-token>" \
    /email:"<email>" \
    /s1:my-server\\sql2019 /db1:my-database /u1:sa /p1:my-password /empty2

To generate a creation script for a live database

docker run --rm --interactive --tty \
    --mount type=bind,src=/home/me,dst=/scripts \
    redgate/sqlcompare \
 	/token:"<personal-access-token>" \
    /email:"<email>" \
    /s1:my-server\\sql2019 /db1:my-database /u1:sa /p1:my-password /empty2 /scriptfile:"/scripts/script.sql"

To compare a live database to a scripts folder

docker run --rm --interactive --tty \
    --mount type=bind,src=/home/me/scriptsfolder,dst=/scriptsfolder \
    redgate/sqlcompare \
 	/token:"<personal-access-token>" \
    /email:"<email>" \
    /s1:my-server\\sql2019 /db1:my-database /u1:sa /p1:my-password /scripts2:"/scriptsfolder"

To connect to a server using 'TrustServerCertificate' and/or 'Encrypt'

# Note the quotation marks surrounding the entire value of the /s1 parameter
sudo docker run --rm --interactive --tty \
	redgate/sqlcompare \
 	/token:"<personal-access-token>" \
    /email:"<email>" \
    /s1:"my-server,port;trustservercertificate=true;encrypt=true" /db1:my-database /u1:sa /p1:my-password /empty2

Didn't find what you were looking for?