In this blog post I am going to show you how to add a SQL Server database to Subversion using Redgate SQL Source Control, the tool claims you can add your database to a source control provider such as Subversion in about 5 minutes – lets see whats involved.

I have Subversion running on my own windows 7 pc at home, I use it for testing out tools and integration with CI and so on, in future blog posts I will cover more on Continuous Integration.

I’m going to start by adding an existing database into Subversion using the SQL Source Control tool with screenshots so you can follow. I currently have Subversion installed and running on c:\svn\trunk\

Below is a screenshot of my local SQL Server

screenshot1

screenshot1

SportsStore is a local database used within one of the MVC books I have, lets add this database to Subversion using the tool now.

Create a New Folder which needs to be empty within your local repository folder, in my case my subversion folder is c:\svn\trunk\ – this is where your database scripts and data will be where your scripts in source control will be locally.

screenshot3

screenshot3

Highlight the database on the left and then select the blue text on the right which says “Link database to source control…”

The following window will pop-up, here enter the url to your repository, since mine is local I just need to add c:\svn\trunk\SportStoreDB (this is the folder your db scripts will go into), click go.

screenshot2

screenshot2

You should see the following :-

screenshot4

screenshot4

At this point the tool has added all the scripts including the data for all your tables to Subversion – now we just need to get this from Subversion into our local folder – to do this right-click on the folder and choose SVN Checkout and then click ok as below

screenshot5

screenshot5

This now leaves us with the entire SportStore database having been scripted and placed within your subversion repository and you now have a local copy – perfect and easily accomplished.

Below are the screenshots of the output from the tool within your Subversion folder.

screenshot6

And a view of the stored procedures folder with created scripts for you.

screenshot7

For more on this great tool check out Redgate SQL Source Control.