Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are using TFS and SQL Server 2005 (looking to upgrade to SQL Server 2012 if that makes a difference). We store our database schema in a Visual Studio Database project (VS 2010).

When code is released to live we currently use the Visual Studio Database Project to build a script for all our schema changes. The problem we have been getting is having to alter or add to that script to add/fix data for the deployment. For example if we add a new non-nullable column to an existing table we need to populate that column with data during the insert. Other times we may want to create new records in transactional tables (e.g. assign specific users to a new security access).

Do Visual Studio Database Projects have a way to store these scripts that only need to be run once and somehow include them in the build? Does it know which scripts need to be run (for example if we are inserting default data we don't want to do that again a second time)?


Is there a better way to manage these scripts?

share|improve this question
<minor quibble> 'SQL' is a query language standard, 'SQL Server 2005' is a particular database product. – DaveE Apr 16 '13 at 16:42
Thanks @DaveE. I am interested in how people manage SQL scripts in TFS against any type of database. The mention of SQL Server 2005 and 2012 was just to give more context on what we're using. – Greg Apr 17 '13 at 1:49

You could consider a branching strategy in TFS. Create a branch from the main, adding your one off's into that which you can deploy. Then create a new branch from the main again, deleting or flagging the previous branch. Your new branch from main will not have the once off's from the previous branch.

Read up on Branch and Merge strategies.

share|improve this answer

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.