RSS 2.0
 Thursday, January 07, 2010

Microsoft has yet to provide us with some kind of utility to handle the importing, managing, versioning, and deploying of data along with our schema changes inside Visual Studio Team System 2008 database projects. For most of the teams I work with, their needs are simple: they just want the ability to store data (INSERT statements are fine) in scripts within their database projects. Ideally the project would be smart enough to know which version of data goes with which version of schema, but for now they’re able to live with handling that manually.

Here’s one solution, albeit a manual one:

1. Create a database project.
2. Import database schema.
3. Launch SQL Server Management Studio (2008 version).
4. Right-click on the database and select Tasks > Generate Scripts.
5. Select the database and under Script Options deselect everything except for “Script Data”.

    ScriptOptions  

6. Click Next and select just the Tables you want (ideally just the smaller, static/lookup tables).

    ChooseTables

7. Click Next and specify the file to generate – something like LookupTableData.sql and let it rip.
8. You can now take that script and add it to your database project in a folder for data-related scripts.

    DatabaseProject

Ideally you would link in the INSERT script(s) to your Post-Deployment script to automatically populate the data tables upon deployment. You can also use the option in the Generate Scripts dialog to give you one file per table, to maximize your versioning options. If you are already using Data Generation Plans, be careful to not overlap what they are already doing. For more information, be sure to read Barclay Hill’s Part 1 and Part 2 of a posting on how to manage data motion during your deployments.

Thursday, January 07, 2010 8:40:03 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
SQL Server | Visual Studio 2008
Navigation
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Accentient, Inc.
Sign In
Statistics
Total Posts: 386
This Year: 7
This Month: 3
This Week: 1
Comments: 376
Themes
Pick a theme:
All Content © 2010, Accentient, Inc.
DasBlog theme 'Business' created by Christoph De Baene (delarou)