I am trying to use the SQL Server Database Project to keep all our table, stored procedure, views etc scripts. I now want a way to be able to keep all our reference (static) data as well. When the tool or project is run it will install all the DB objects and the insert all the reference data.
I found similar articles for vs 2010 but they were using things like Team Edition for Database professionals.
- Get our DB under source control.
- Synchronize our local development DB with latest version in source control.
- Work with Visual Studio 2012 and SQL Server 2012
- Use .Net tools as far as possible and not something like Redgate (Redgate is great but I don’t want to for out for it just yet if I can use tools in VS 2012)
You can use this approach:
Here is a more detailed description of each step, illustrated with an example. Let’s say that you need to initialize a table of countries that has this structure:
Create a new folder called
ReferenceDataunder your database project. It should be a sibling folder of theSchema ObjectsandScripts.Add a new XML file called
Country.xmlto theReferenceDatafolder. Populate the file as follows:Find
Script.PostDeployment.sql, and add the following code to it:I tried this solution only in VS 2008, but it should be agnostic to your development environment.