Comparing and Deploying SQL Server Databases Using the SQL Compare Command Line on Linux or Windows

SQL Compare Command Line

SQL Compare now includes a Linux-based command line interface (CLI) as well as a Windows-based one for doing schema comparison and deployments of SQL Server databases. This article offers examples of CLI scripts for various schema comparison tasks to get you up and running with either version.

You may also like:  Data and Schema Comparison Tools for MS SQL Server Databases (Part 1)

Contents

On investigating the new SQL Compare command line for Linux, I wanted to try out a range of its features, so I installed it directly on a Linux-based Synology NAS server and used it to access SQL Server instances on the network and to process files such as backups directly on the Linux filesystem.

Integrating SQL Server Tools Into SQL Change Automation Deployments

SQL Change

hen doing repetitive database work with SQL Change Automation (SCA) or SQL Compare, we often need to use other tools at the same time such as the registered servers in SQL Server Management Studio (SSMS), SQLCMD, and BCP. I also tend to use the SQL Server PowerShell module, sqlserver (formerly known as sqlps). This uses Server Management Objects (SMO), which is Nature's Way of interacting with SQL Server and uses the same .NET library that underlies SSMS.

You might also enjoy:  Simple Steps in SQL Change Automation Scripting

If you do so, you'll want to integrate all these tools as much as possible, and when you're scripting with PowerShell, use the same database connections as you are using with SCA. This article is all about how you do that. We'll show how you can start integrating SCA scripts with SSMS into a single process, and we'll also learn to stop fearing the connection string and view it as an ally. We will use one to create an SMO connection via a serverConnection object and borrow that same connection to execute BCP and execute a SQL Command.

Running Linux SQL Server as a Container

Phil Factor starts a series of articles that will demonstrate the use of temporary SQL Server instances and running in Linux containers, into which we can deploy the latest database build stocked with data for development and testing work. This initial article shows how to set up a SQL Server instance inside a Linux Docker container, create some sample databases, and persist data locally.

Running Linux SQL Server as a container in a Windows Virtual Machine is valuable for development work. It saves time in setting up development and test environments. It provides a standard environment for running databases. There are limitations, however. Currently, Windows authentication isn't supported, and running containerized database applications in production isn't generally recommended due to the increasing isolation from the filesystem that can affect caching and the server's response to failure cases in the filesystem.