Click here to Skip to main content
15,883,901 members
Articles / Desktop Programming / WPF
Tip/Trick

SQL Deployment Tool for Multiple Databases

Rate me:
Please Sign up or sign in to vote.
4.40/5 (5 votes)
13 Nov 2010CPOL2 min read 24.2K   7   5
Executes SQL scripts in multiple databases at once.

Introduction


Don’t you feel annoyed if you want run the same scripts in multiple databases over and over. I had the same situation at my work. So I made a small tool in WPF using MVVM architecture. I hope this may be helpful to you.



Background


I have a situation whenever I make changes or develop stored procedures I have to run in couple of databases. Sometimes I forget to run in a few databases that cause an application error. So I decided to write an application to do this laborious job.



Using the Code


This tool is very light, the reason I called very light because I am not loading servers and databases information from the network. I feel it is overhead and shows more than you wanted. This tool reads this information from ServerConfig.xml file, you can add only information (Servers and Databases) you want to use in the XML file.


**This File must be located in application folder (Ex: bin/Debug or bin/Release)


EasyDeploy_config.JPG

All you need to configure is the DisplayText and Tag in the XML, you can disregard the rest of the stuff.

DisplayText – The text you see in the user interface, for example, server name in the server dropdown.
Tag – Actual name of the server/database


If you configure your settings in XML file, you are ready to use the application. The following picture shows the sequence of steps to how to use this tool.


SQL_Deploy.JPG


Here are the steps again:



  1. Select authentication (Windows or SQL authentication), if it is SQL authentication enter valid user name and password.
  2. Select databases where you want to run your scripts.
  3. Select a script file if you have script already in the file, or you can type in your SQL script in the text area. If you have multiple SQL statements, each statement must end with a semicolon or enclose each statement between BEGIN and END to execute everything at once. Otherwise you will have to select each SQL statement at a time to execute.
  4. Click execute button to run the SQL statements
  5. You can see success or failure messages in the bottom of the application.
  6. Click clear to clear text area.


Points of Interest


I wanted to write a small useful application using WPF and MVVM.



History


10/25/10 Initial release

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralThis is exactly what I was looking for... In one of my work... Pin
hfeiges31-Aug-11 6:27
hfeiges31-Aug-11 6:27 
GeneralRe: That is a good idea, unfortunately this tool doesn't support... Pin
Srinivas-Miriyala31-Aug-11 6:53
Srinivas-Miriyala31-Aug-11 6:53 
GeneralThanks for your vote and advice but it is possible to execut... Pin
Srinivas-Miriyala4-Nov-10 5:59
Srinivas-Miriyala4-Nov-10 5:59 
GeneralReason for my vote of 3 comment already added Pin
Sivaraman Dhamodharan2-Nov-10 1:55
Sivaraman Dhamodharan2-Nov-10 1:55 
GeneralWhat is the advantage if it does not allow executing mutiple... Pin
Sivaraman Dhamodharan2-Nov-10 1:55
Sivaraman Dhamodharan2-Nov-10 1:55 
What is the advantage if it does not allow executing mutiple statements?
If I have a script file that have 40 statements, I should prefer the traditional way of executing 40 statements separately on Db1, Db2, Db3 and Db4. [4 Execution]
Not a 40 Execution.

The idea is good if overcome the restriction specified.
Thanks for sharing. My vote of 3

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.