Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to version control SQL Server databases?

I have SQL Server databases and do changes in them. Some database tables have records that are starting records required my app to run. I would like to do version control over database and these records (rows). Is it possible to do this and bundle it to SVN version control I have for my source code or are there other solutions to this? I would like to accomplish this to be able to return to previous version of database and compare changes between database revisions. It would be nice if tools for this are free, open source or not very expensive.

My environment is Visual C# Express, SQL Server 2008 Express and Tortoise SVN.

like image 608
Tom Smykowski Avatar asked Mar 23 '09 09:03

Tom Smykowski


People also ask

What is Redgate SQL Source Control?

What does SQL Source Control do? SQL Source Control plugs into SQL Server Management Studio (SSMS) and links your databases to an existing version control system, such as Git, TFS or Subversion. This allows you to manage changes to database schema and static data alongside application code.


1 Answers

Late answer but hopefully useful to other readers

I can suggest using the SSMS add-in called ApexSQL Source Control. By utilizing this add-in, developers can easily map database objects with the source control system via the wizard directly from SSMS. It includes support for Git, TFS, Mercurial, Subversion, TFS (including Visual Studio Online) and other Source Control systems. It also includes support for source controlling Static data (so you can version control records also).

After downloading and installing ApexSQL Source Control, simply right-click the database you want to version control and navigate to ApexSQL Source Control sub-menu in SSMS. Click the “Link database to source control” option and select the source control system and the database development model, for example:

enter image description here

After that, you may exclude objects you don’t want to be linked to source control. It is possible to exclude specific objects by owner or type.

On the next step, you will be prompted to provide the log-in information for the source control management system:

enter image description here

Once done, just click the “Finish” button and the “Action center” window will be shown, offering the objects that will be committed to the repository (this is by default, if the repository is empty).

Once the database has been linked to source control, all the operations that can be executed from a source control client will be available from the “Object Explorer” pane. Those include:

  • checking out with or without lock the versioned objects,
  • view history of that object and apply specific revision,
  • view changes on that object that were made and
  • place data from table to source control using the “Link static data”

You can read this article for more information: http://solutioncenter.apexsql.com/sql-source-control-reduce-database-development-time/

like image 78
Thomas Bovee Avatar answered Oct 20 '22 22:10

Thomas Bovee