Executes sql scripts for production from a directory.
- Sql is stored in a flat directory.
- Files are ordered by a filename convention in the way they should be executed.
- Each sql script should be executable based on the same connection string.
- Each sql script is encapsulated.
- Any
GO
keywords should be removed. See below.
SSMS contains a GO
keyword which allows for a break between two independent statements in the same execution. This keyword is not, in fact, valid SQL and should be removed prior to execution in this program. It also is not best practice to include this keyword since it means that one file contains more than one unit of work. For instance, commands that are required to be the first statement should instead be split into new scripts. Use of the semicolon ";" to indicate a statement's end is encouraged. You will be alerted if the GO
keyword is found and the file will not be executed.
- Each sql script should accomplish one unit of work.
- Each sql script should protect itself from duplicate execution.
- Each sql script should be dynamic, using variables where possible.
- Each sql script in the directory should act on the same database (no use keywords).
- Each sql script should have no or minimal output.
- Comment liberally.
Please see Arguments.cs
for a complete list of arguments.
SqlDeploymentExecutor.exe -d "C:\Deployments\Scripts\1.0.0" -c "Server=<SERVER>;UID=<UID>;PWD=<PWD>;Initial Catalog=<DATABASE>;"