Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am currently using Tortoise SVN to source control a .NET Web Application. What would be the best way to bring our SQL Server stored procedures into Source Control? I am currently using VS 2010 as my development environment and connecting to an off-premise SQL Server 2008 R2 database using SQL Server Data Tools (SSDT).

What I have been doing in the past is saving the procs to a .sql file and keeping this files under source control. I'm sure there must be a more efficient way than this? Is there an extension I can install on VS2010, SSDT or even SQL Server on the production machine?

share|improve this question
If you're using the SSDT project type in Visual Studio, add that project to source control. That's it. –  Mark Storey-Smith Mar 26 '13 at 16:10
Please clarify your objective(s) -- are you just looking for versioning of the database objects, or are you trying to use this as a deployment platform as well? –  Jon Seigel Mar 27 '13 at 1:24
add comment

5 Answers

up vote 6 down vote accepted

There are tools out there, such as this from Redgate, but I have always found that best is to save as SQL files, perhaps even in a Database Project (SSDT?) in your solution.

Along with this, I suggest the following guidelines:

  • Always assume the SVN version as the "current" / "latest"
  • Ensure that every script you run has an appropriate "if exists then drop" at the start
  • Remember to script your permissions, if any

You can initially create these SQL files by scripting directly from SSMS, and you can set SSMS to script all your "drop" and "create" as well as your permissions.

share|improve this answer
I was unaware of the database project type and have only just started exploring SSDT, but this looks promising. I've opted for this solution as there's no dependency on 3rd party tools and I can easily drop the .sql files into our current Source Control. –  QF_Developer Mar 27 '13 at 9:41
Also do not allow rights to devs on prod and those with rights only deploy from source control. –  HLGEM Apr 2 '13 at 14:02
add comment

Try Ankhsvn, highly recommended and free.

From the homepage:

AnkhSVN is a Subversion Source Control Provider for Microsoft Visual Studio 2005, 2008, 2010 and 2012.

AnkhSVN provides Apache™ Subversion® source code management support to all project types supported by Visual Studio and allows you to perform the most common version control operations directly from inside the Microsoft Visual Studio IDE.

The Pending Changes dashboard gives you a unique insight in your development process and provides easy access to the source code and issue management features. The deep source code control (SCC) integration allows you to focus on developing, while AnkhSVN keeps track of all your changes and provides you the tools to effectively handle your specific needs.

share|improve this answer
add comment

Saving the SQL files in source control provides control over the SQL files only. It doesn't control the changes of the actual database objects, nor it prevents simultaneous changes of the same database object by multiple users (and I guess you would like to have that under control, too). What we use is a 3rd party tool (ApexSQL Version), it integrates both with SSMS and VS, you can chose whether to work with a database version of the object, or with a Source Control version. If you're editing a database version, it's automatically checked out only to you, so no one else can edit it (it doesn't merge changes from different users). Only when you check it in again, others can modify it. And you can have your SC version different from the version of a live object (I use that when I leave for the day and plan to finish the edits and test it on the next)

share|improve this answer
add comment

Use RedGate Source Control to hook it up to your source control.


It will hook your SSMS directly to your source control repository and even allows for checking in static data.

Works like a charm

share|improve this answer
add comment

There's also this option: (somewhat different take that what Red-Gate does, but still does the job with little effort on your part)


share|improve this answer
If you are associated with the product mentioned, you need to show that in your answer. Either way, you should attempt to put more details into your answer - what does the product do/not do, why is it great, etc. –  Max Vernon Apr 2 '13 at 14:58
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.