How to keep Stored Procedures and other scripts in SVN/Other repository?


Can anyone provide some real examples as to how best to keep script files for views, stored procedures and functions in a SVN (or other) repository.

Obviously one solution is to have the script files for all the different components in a directory or more somewhere and simply using TortoiseSVN or the like to keep them in SVN, Then whenever a change is to be made I load the script up in Management Studio etc. I don't really want this.

What I'd really prefer is some kind of batch script that I can run periodically (nightly?) that would export all the stored procedures / views etc that had changed in a given timeframe and then commit them to SVN.



Based on your expanded question, you really want to use DDL triggers. Check out this article that details how to create a changelog system for your database.

By : Josef

I wrote a utility for dumping all of the relevant parts of my db into a directory structure that I use SVN on. I never got around to trying to incorporate it into the Manager but, if you're interested, it's here:

It's free and, since I regularly run it, you know any bugs get fixed quickly.

By : Josef

I can recommend DBPro which is part of Visual Studio Team Edition. Have been using it for a few months for storing all parts of the database in Team Foundation Server as well as for deployment and database compares, etc.

Of course, as someone else mentioned, it does depend on your environment and price range.

This video can help you solving your question :)
By: admin