SVN Auto-commit files

Many times you would like to have a version control on your database. Here is a simple recipe how to set this up on you SQL Server datbase. And sometimes you need to set up automatic commits to SVN (or other version control system). Here is how to do it:

REM Script out database: all the tables, stored procedures, functions, etc.
REM then add missing files to the SVN version control
REM and commit all the changes to the repository.
REM Provide a comment for the commit as a parameter to this batch.
REM This is used as a scheduled task job - once a week do an automatic commit.

scriptdb -con:"Data Source=myServer;Initial Catalog=NorthenLights;user id=sa;pwd=password" -outDir:scripts -nocollation
cd d:\SQL_versioning\
"c:\Program Files\TortoiseSVN\bin\svn" add --force * --auto-props --parents --depth infinity -q
"c:\Program Files\TortoiseSVN\bin\svn" commit -m %1%

I hope I don’t need to tell you that you need to have TortoiseSVN installed, along with ScriptDB. If you are using SQL Server 2008, you can use my build for ScriptDb as the provided executable file does not work with SQL Server 2008 and 2012. Also don’t forget to modify the connection string for your database.