Introduction
Microsoft's SQL Server Management Studio allows you to have a project to organize scripts and also lets you add "External Tools" that can interact with your projects. The downside is: when a large amount of scripts from a project need to be executed, they must be opened and executed one by one. I found an article that executed all of the scripts in the project that works great when all of the scripts need to be executed, but I needed a tool that could execute the scripts in a specified order.
How the Code Works
The Management Studio calls the program with “$(ProjectDir),$(ProjectFileName)” arguments passed in, and the wizard finds the project, which is stored with XML, and reads the files. The wizard will set some options up for the execution, then execute the files asynchronously, allowing users to stop execution.
Installing External Tools
To install:
- Go to Tools (on the main menu) -> External Tools...
- Add a new tool by clicking Add
- Give the tool a title. for the command, locate the ExecuteAll.exe
- Arguments must be
$(ProjectDir),$(ProjectFileName)
- Leave the Initial Directory blank
Note: The check-boxes do not affect the way the program runs.
Conclusion
This wizard makes projects more useful and easier to execute. Feel free to modify the source code. To see a simpler example of a Microsoft SQL Server Management Studio, please visit this article. For more information about using this program, there is documentation in the download file.
History
- 7/18/2008 - Fixed an error with separating batches by "GO"