A tool to run SQL scripts against multiple MSSQL databases.
When you're working on a multi-tenant application, chances are you have multiple databases (one for each client).
And there will come times (hopefully not often) when you may need to run a query or a patch across multiple (or all)
clients. In SQLServer, the quick and dirty way to accomplish this was to dynamically generate your query and joined it
with USE
statements. It was simple enough to do and it got the job done.
However in Azure SQL that is not possible because the USE
statement is not allowed.
You can purchase a tool like Red Gate's SQL Multi Script, which
is a pretty good tool,
OR as the saying goes "why pay for something when you can do it yourself?"
Download the latest release from here. Then just unzip and run the MDbScriptTool.exe
.
Important! Windows block content downloaded from the internet. Prior to extracting the zip file, unblock it by viewing the zip file properties and unblocking it.
-
The Web Essentials 2019 extension is used to compile
css
andjs
files for releases. Install the extension from the VS market place. -
The AutoRunCustomTool extension is used to re-compile the t4 template automatically whenever the
*.tt.html
file changes.
If building from a fresh download/clone:
- Right-click on solution and choose Restore NuGet Packages
- Right-click on project and choose Web Compiler > Re-compile all files
- Right-click on project and choose Bundler & Minifier > Update Bundles
- Rebuild Solution
Important! Windows block content downloaded from the internet. Prior to extracting the zip file, unblock it by viewing the zip file properties and unblocking it.
Here are some other alternatives.
- Red Gate's SQL Multi Script - Commerical tool
- ApexSQL Propagate 2018 - Free Commercial tool
- xSQL Script Executor - Free for Personal Use
- TakoDeploy - Open Source
- Sp_MSforeachDB - Undocumented procedure (Doesn't work on Azure)