Click here to Skip to main content
13,453,348 members (50,868 online)
Click here to Skip to main content
Add your own
alternative version


23 bookmarked
Posted 30 Jan 2004

Version Control For Database Scripts

, 30 Jan 2004
Rate this:
Please Sign up or sign in to vote.
An article on version control for database scripts.

Control versions of database scripts in 10 simple steps.

The purpose of this article is to empower users with the power of Visual Studio .NET (VS.NET) and Visual Source Safe (VSS). In vast number of projects, .NET code is versioned through VS.NET, but versioning of database scripts is done through traditional use of VSS, i.e., checking out and checking in the files in folders. Maintaining exact versions of scripts in post-implementation support phase and maintenance phase becomes difficult and erroneous if VS.NET is used as a tool for versioning of database scripts. This article shows readers in 10 simple steps to use this very powerful feature of VS.NET.

Step 1)

Create database connections through Visual Studio .NET. Click on ‘View’ in the main menu as shown in fig 1.

Step 1

Step 2)

On click of ‘Server Explorer’ sub-menu, Server Explorer pane will be displayed with Database Connections and Servers in the tree menu. Right click on Database connections and click ‘Add Connection…’ as shown in fig 2.

Step 2

Step 3)

Add Connection sub-menu opens a tabbed window. Enter database server name, username, password and database to connect. Also check on the checkbox ‘Allow saving password’ as shown in fig 3.

Step 3

Step 4)

Message pop up is displayed as shown in fig 4. Click on ‘OK’.

Step 4

Step 5)

Now, open a blank solution and add a Database project in the Other Projects folder as shown in fig 5.

Step 5

Step 6)

A pop up will be displayed to choose from database connections already made, or to make new one, add it as a reference to the project. Choose the one on which the scripts are required to be run by clicking on one of them. Refer fig 6.

Step 6

Step 7)

Database project is added to the solution with two folders Change Script and Queries. Remove these folders and add as per the project requirement. Also add the scripts generated for the tables.

Step 7

Step 8)

Add the solution to VSS by right-clicking on the solution and clicking on ‘Add Solution to Source Control…’ as shown in fig 8.

Step 8

Step 9)

Now, open a file and try to edit it. Window to check out the file will open as shown in fig 9. This means that the scripts are now under Source Control.

Step 9

Step 10)

Any changes to the file are done locally. For the changes to take place on the server, the scripts have to be run on the server. This is done by right clicking on the changed file and clicking on ‘Run’ as shown in fig 10. This will run the scripts on the database, which was added as a reference when creating the project. To run the scripts on some other database, click on ‘Run On…’.

Step 10


I hope implementation of the 10 simple steps in your future projects saves your time and effort.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralAny specific Order or categorisation Pin
Basel Nimer22-Feb-10 2:23
memberBasel Nimer22-Feb-10 2:23 
GeneralVS 2005 Pin
yuval ashkenazi10-Nov-06 4:28
memberyuval ashkenazi10-Nov-06 4:28 
GeneralRe: VS 2005 Pin
gopala krishna G21-Feb-07 0:58
membergopala krishna G21-Feb-07 0:58 
you need to add scripts to the project manually...
there are 2 ways....
1) if u use sqlserver 2000, generate scripts for your database with "single file for object". and add these file to your database project. sql server 2005 wont support this... it creates single file for all the scripts.
2) if u use sqlserver 2005, open server explorer and connect to the reference database. click on each object and select "generate script to project"... this will add scripts to project but one at a time. You can use scriptio (tool which helps u generate a file for each object with sqlserver 2005) to generate script files

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180318.3 | Last Updated 31 Jan 2004
Article Copyright 2004 by kutubshikora
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid