Search code examples
.netsql-serverdatabasesvnstored-procedures

How do I add existing SQL Server stored procedures to source control?


Right now we have a bunch of database servers with stored procedures running in them that are poorly documented and exist nowhere else.

When a change is made to one, there is no log, and it's really hard to figure out why something that was working suddenly fails.

We've recently switched to using proper version control using SVN, so I was hoping to add these stored procedures to version control.

We are a .Net shop, and I'm aware that there exists a Database project type. Would that be a good approach?

Alternatively I could just keep the stored procedures as text files and operate on those, but I'm wondering about the annoying deployment steps involved with doing so.


Solution

  • In Visual Studio, I created an empty project and added the scripts to it. Its part of my server schema solution. Now every single script in under source control. I also added a folder structure as well to try and keep the sanity. When the application is finished we will have probably close to 3000 scripts under source control under multiple server schemas. Not saying this is the best, but it is working for our project. The solution also has a utility which uses SMO to actually run/deploy all the scripts, so everything is contained in one solution. Screen shot attached showing some of the structure for your reference...

    Source Control Scripts