You can use the Migrate Data wizard, which
can be invoked from the Deployment Script Editor, to
generate the change commands that are necessary to copy data. Those commands
can then be deployed to the database.
Prerequisite: A deployment script for the database to which
you plan to move data must exist.
To copy data, complete the following steps:
- Open the deployment script in the Deployment Script Editor.
- Click the Change Commands tab to display
the Change Commands page.
- On the Change Commands page, click Generate Data Migration. The Migrate Data wizard starts.
Complete the steps in the wizard
to generate your commands. The wizard takes you through steps to specify information
for:
- Selecting the data migration options.
You can either generate the change
commands so that the files are standalone or so that they are integrated into
the deployment script. When you generate them to be standalone, you deploy
them to the database by right-clicking the change command file in the Data
Project Explorer, and clicking Run SQL. When you have them integrated
into the deployment script, you can deploy them to the database from the Deployment
Script Editor.
- Selecting the source connection.
You must identify a connection for
the database from which you want to copy data.
- Specifying file information.
You must specify a directory for the export
and import commands that will be generated for copying the data from the source
database to the target database. You can change the method that will be used
to unload and reload the data.
- Specifying the mapping tables.
The wizard includes pages for specifying
information for generating the export and import commands. You must identify
the pairs of tables from which to save data and into which to load the saved
data. Use the Add New Entry icon to add a table entry.
- Customizing export and import commands for data migration.
You can customize
the commands that unload and reload the data and map the columns between tables.
- Merging change commands.
If you chose to have the change commands generated
so that they are integrated into the deployment script and the deployment
script contains other change command files, you are prompted to merge the
changes from the Previous Change Commands side of the Merge
Editor to the Proposed Change Commands side
of the editor. Merge the commands, ensuring that referential integrity is
preserved. That is, ensure that the parent table in any referential integrity
relationship is loaded before the child table.
- Deploy the change commands to copy the data from the source database
to the target database, using one of the following methods:
- If you generated the change commands to be standalone:
- In the Data Project Explorer, right-click the change commands file that
contains the export commands, click Run SQL, and complete the steps
in the Deploy Change Commands wizard. Repeat this for each export file.
- Right-click the change commands file that contains the import commands,
click Run SQL, and complete the steps in the Deploy Change Commands
wizard. Repeat this for each import file.
- If you generated the change commands to be integrated with the deployment
script:
- With the deployment script open in the Deployment Script Editor, click
the Change Commands tab to display the Change Commands
page.
- On the Change Commands page, click Deploy Changes to the Target
Database .
- Complete the steps in the Deployment wizard to deploy the changes. The
changes for all of the change command files that are contained in the deployment
script are applied.
There is no way to automatically back out migrated data because you
cannot generate undo commands for data migration. However, if you deploy undo
commands to roll back the changes that you have made to a database and a table
is dropped and re-created as part of the undo, any data that you have copied
over is effectively lost.