When work on a database in a development environment is completed, developers are required to send the new version in for testing. If the testing is done on one or two machines – this is not a problem. However, if there is a need to test the new version on 10 or 15 machines (with different operating systems, SQL Server versions, or service packs installed), this can be tedious.
Another situation where scripts need to be executed on multiple servers is if there are many databases for different clients that were all derived from the same database and share many common objects. Any changes made in the development must be pushed to all users.
Deploying multiple SQL scripts to multiple servers manually can be a very time-consuming task, where identical steps need to be repeated over and over again until all databases are updated. This is especially true during the development and testing phase when there are many changes that need to be deployed for testing each day.
The challenge is how to deploy multiple scripts to multiple servers quickly and safely.Use SQLCMD
:CONNECT <server1>\,<instance1> --SQL1 to execute GO :CONNECT <server2>\,<instance2> --SQL2 to execute GO
SQLCMD –I D:\Scripts\BatchMultiple.bat
A disadvantage of this method is that it requires numerous manual and time-consuming actions, which are very error prone. Each time when new scripts are executed, the batch file must be modified or a new one has to be created.
Use Server groups






USE Adventureworks2014; ALTER TABLE TestTabM ADD colb int;
Command(s) completed successfully. (2 servers)
SQL was executed against all Adventureworks2008 databases in the Server group (in this case – 2)
The disadvantages of this method are that the scripts can be deployed only against all registered servers, the database names have to be identical on all registered servers, and executing multiple scripts requires manually opening and pasting them into the Query Editor window one by one.
Use ApexSQL Build
ApexSQL Build is a SQL database deployment tool, which builds new databases or updates existing ones by packaging SQL scripts, script folders, database snapshots, and scripts under source control. It ensures error-free deployments and enables executing SQL scripts against multiple SQL Servers simultaneously by creating personalized lists of databases on different SQL Server instances and lists of SQL that should be executed.


Click the Save list in the menu to save the list of scripts:





The execution progress bar will be shown:

When the deployment is finished, a summary will be shown:
Deployment of multiple SQL on several different SQL Server instances and databases can be easy and error-free. Select a database on any SQL Server, select the scripts you want to execute, save them to lists, and reuse whenever you want.