Add SQL Objects to TFS/ Version Control

  • I work for a small company and we are trying to get all database objects in to TFS. Our dot net code is already in TFS but SQL objects code still not in source safe.

    We use TFS 2005 and Visual Studio 2005 and SQL 2008.

    Currently we only add SQL objects to TFS if we make changes to it recently. What we are trying to do is add all objects in to TFS one time and then manage it from within TFS - this will give us a history of all changes and also help us version the scripts.

    One issue though - we need to maintain different versions of the code since some of our customers are in different versions. Like our latest build is 7.3.0 but some customers are in 7.0.0. and some are in 6.x.x etc.

    So every time we start a new build effort, we branch the code and start developing in the version.

    How will the SQL objects be managed if we are to create a branch and yet maintain history of changes?

    Are we trying to accomplish too much? Would you have any ideas on to do this (add SQL objects to TFS and Source Control at the very least)?

  • Have you looked into using Red Gate's SQL Source Control, http://www.red-gate.com/products/sql_source_control/index.htm. It allows you to source control your db schema objects in TFS direclty from SQL Server Management Studio.

  • This is not a solution.

    I hope it should be inbuilt functionality into TFS 2010.

    Thanks

    Regards

    Shyam

  • Any chance you can upgrade to Visual Studio 2010 or later? SQL Server Data Tools, which is available in 2010/2012 is pretty darn useful, and it makes database development much easier. May not be an option in your case, but it might be worth looking into.

    What I've done with past versions of Visual Studio is to script out objects from the database (which can easily be done with SQL Server Management Studio) and then I stuff them into a database project in VS. And from that point on, any database work I'd do in SQL Server Management Studio and just use the Visual Studio database project as a "dumb" repository to keep TFS in synch with my work. With SQL Server Data Tools though, I've moved my development over to Visual Studio almost entirely. Integration with TFS works well, and I'm able to develop and deploy changes without having to go back and forth between VS and SQL Server Management Studio.

    As far as branching your code, it seems like you're doing it right if you need to start a revision for a particular customer. I think what you are missing is what you do with the branch once you are done with it and how to deliver the updates to the customer. Your branch needs to be merged back into the code that you branched from (back to the "trunk", the "trunk" being the baseline of code that you branched from). But then, if you have multiple customers on different versions, you may actually have a set of baseline "trunk" code lines that you have to manage, one per customer. But the basic idea is that you branch code from a trunk baseline, make your changes to the branch and once it's tested and ready, merge that branch back to the trunk and then deliver the code to the customer as a "release" (and the the "release" can just be a branch from the newly updated trunk).

    Anyway, this is just one way to manage your version control system, it's what we use where we work but it may not be appropriate for you. Hopefully gives you some ideas though.

  • Thanks,

    However I am trying to add Sql server database into TFS using VS 2012.

    I hope this should work.

    Can you please list out some steps to add Sql Database project into TFS using VS 2012

    Thanks again.

    Regards

    Shyam Raghuvanshi

  • Well, we don't use VS 2012 yet and I've not tried this with VS 2012, but I'll give it a shot.

    1) Get Sql Server Data Tools! Download and install the appropriate version for you, there's one for VS 2012.

    http://msdn.microsoft.com/en-us/data/hh297027

    2) Create a new database project (make sure it's the SQL Server Data Tools project though, and not the default Visual Studio database project)

    3) Reverse-engineer your database into your project. I use the "Schema compare" feature to do that, but I don't think that's the only way.

    4) Add your project to TFS

    That's basically it. Once you have the project in Visual Studio and have added it to TFS, you're pretty-much good to go.

    You'll need to do your own research on how to use SQL Server Data tools, there's a lot to it and I can't possibly explain it all, especially since I don't use all of its functionality. There's plenty out on the internet to show you how to do that, though. Here's a link to a Tech-ed presentation on it:

    http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV207

    But google for SSDT or "SQL Server Data Tools" and you'll find lots of info.

  • If you have VS 2012 installed. You must install SSDT 2012 on the same box. Then when you create new project you will see the DATABASE project template. After you create a new database project then you extract all SQL objects from the SQL Server. 🙂

    Hope this help!

    ----- Zack

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply