0

I have a build-definition in TFS that builds a database-project in Visual Studio. The output is a dbschema and some other files. With that dbschema I deploy that Database to another server by using vsdbcmd. This works fine to deploy the Database structure/schema.

Is it possible to also deploy the data/content of the original database to the other database? Or also put the db-content in the output from the build-definition?

Thanks

Mathieu
  • 3,073
  • 1
  • 19
  • 25

2 Answers2

1

You can include INSERT statements in the PostDeploy sql script within the DB Project to generate any data you need.

If you want to generate these INSERT statements en-masse you can use the Data Compare tool to compare a DB with data to one without, and it will gen all the INSERT statements you need that you can then copy-paste into the PostDeployment script.

Dylan Smith
  • 22,069
  • 2
  • 47
  • 62
  • Can I do this in command line? I want this to be automatic in the Build Definition. – Mathieu Oct 11 '12 at 08:33
  • If you put it in the PostDeploy script, you won't need to do anything, it will just work. – Dylan Smith Oct 11 '12 at 08:49
  • I mean, can do the "Data Compare" and generate a INSERT statement in command line? – Mathieu Oct 11 '12 at 08:53
  • 1
    If the data is static I'd recommend just generating the static insert's once and checking them into the project. If the data changes and you want to automate this, I'd recommend using a Data Generation Plan (Select the Data Transform Plan subtype), and you need to point it to an existing database via a connection string that it can use at deploy-time to read the data needed. – Dylan Smith Oct 11 '12 at 15:39
0

We use SQL Merge-scripts (scriptfiles with MERGE-stmts) in our post deployment scripts to keep lookup tables in the database(s) up-to-date. Create a script file for each lookup table (merge stmt) and reference these files from your post deployment script. Sometimes it can be necessary to drop FK relationships before loading data into lookup tables and to load them in a certain order. We've created two scripts, one that run before merge scripts, drops FKs, the and a second that run after merge scripts, recreates FKs. Works fine for us.

pakerblom
  • 23
  • 3