Dasun
Dasun

Reputation: 19

How to get data changes as an update script from two dacpacs

From a two .dacpac files I can get the update script using following command

sqlpackage.exe /Action:Script /SourceFile:"C:\Test\bin\Debug\Test.dacpac" /TargetServerName:localhost\DenaliRC0 /TargetDatabaseName:deploy_Test

How ever this will generate only DDL changes (schema changes). But that not included any data changes. Is there anyway I can get those Data changes (DML) from two dacpacs?

Flowing is the java code i use to get schema changes.

 CommandLineUtils.execute(this.log, "sqlpackage.exe", new String[]
{
  "/Action:Script",
  "/SourceFile:" + targetDacPac.getAbsolutePath(),
  "/TargetFile:" + previousDacPac.getAbsolutePath(),
  "/OutputPath:" + scriptOutput.getAbsolutePath(),
  "/TargetDatabaseName:changeme",
  "/p:ScriptDatabaseOptions=False",
  "/p:IgnoreAuthorizer=True",
  "/p:IgnoreLoginSids=False",
  "/p:DropObjectsNotInSource=True",
  "/p:IgnoreFilegroupPlacement=False"
});

Upvotes: 0

Views: 3551

Answers (1)

Peter Schott
Peter Schott

Reputation: 4726

I think you need to look at pre and post-deploy scripts to handle getting your data into the table and/or modifying existing data. SSDT (and its predecessors) do not handle data within the project except for what is called a "bacpac" file. That's a one-time schema and data combination with the schema stored in the normal XML format and data stored in native format BCP files (if I understand it correctly).

I'd recommend checking out this article on pre/post deploy scripts: http://schottsql.blogspot.com/2012/11/ssdt-pre-and-post-deploy-scripts.html

You can also see what I've written on SSDT here - you may find something helpful: http://schottsql.blogspot.com/2013/10/all-ssdt-articles.html

Upvotes: 2

Related Questions