Click here to Skip to main content
Click here to Skip to main content

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

Conclusion

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

License

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

Share

About the Author

kutubshikora
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralAny specific Order or categorisation PinmemberBasel Nimer22-Feb-10 2:23 
GeneralVS 2005 Pinmemberyuval ashkenazi10-Nov-06 4:28 
i tried to run this solution with vs 2005 but the all db scripts wasn't create inside my project.
maybe you have solution fot this?
GeneralRe: VS 2005 Pinmembergopala krishna G21-Feb-07 0:58 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140826.1 | Last Updated 31 Jan 2004
Article Copyright 2004 by kutubshikora
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid