Migrating data from SQL Server to Db2
You can migrate the data from SQL Server to Db2 and configure Jazz® Reporting Service to use the new database.
Procedure
- Create a new Db2 database.
- Before you migrate the data to Db2, create the data warehouse schemas and tables in the new Db2 database by configuring your database with JTS Server as a data warehouse.
- After you connect to the database, click Create Tables to create the new schemas and tables for the data warehouse.
Alternatively, you can shut down an ELM server that has the data warehouse with the Db2 database and run following command:
repotools-jts –generateWarehouseDDLScripts
- In the repotools-jts_generateWarehouseDDLScripts.out directory, run the SQL scripts in sequence.
- Before you migrate the data to Db2, disable the foreign key constraints in all data
warehouse tables in the Db2 database. Save the following script in
disableFKConstraints.sql file in SQLLIB\BIN folder:
BEGIN FOR v_row AS SELECT TABSCHEMA, TABNAME, CONSTNAME FROM SYSCAT.TABCONST WHERE TABSCHEMA IN ('CONFIG','RICALM','RIDW','RIODS','RIASSET','RISCHK') AND TYPE = 'F' DO EXECUTE IMMEDIATE 'ALTER TABLE ' || v_row.TABSCHEMA || '.' || v_row.TABNAME || ' ALTER FOREIGN KEY ' || v_row.CONSTNAME || ' NOT ENFORCED'; END FOR; END@
- Run the following command in Db2 Command Window:
db2 -td@ -vf C:\IBM\SQLLIB\BIN\disableFKConstraints.sql
- Drop the Triggers in all data warehouse tables in Db2 database. Save the following script
in dropTriggers.sql file in SQLLIB\BIN folder.
BEGIN FOR v_row AS SELECT TRIGSCHEMA, TRIGNAME FROM SYSCAT.TRIGGERS WHERE TRIGSCHEMA IN ('CONFIG','RICALM','RIDW','RIODS','RIASSET','RISCHK') DO EXECUTE IMMEDIATE 'DROP TRIGGER ' || v_row.TRIGSCHEMA || '.' || v_row.TRIGNAME; END FOR; END@
- Run the following command in Db2 Command Window:
db2 -td@ -vf C:\IBM\SQLLIB\BIN\dropTriggers.sql
- Obtain ESF Database
Migration Toolkit or comparable tool to migrate the data. Note: IBM provides services to migrate data. For more information, contact your IBM account representative.
- Install and run the Database Migration Toolkit.
- Click
Settings > General tab and
update the following fields:
- In the If Table Exists: field, select Empty Data.
- Clear the Copy Structure Only, Transfer Auto-Increment, Copy Indexes, Copy Foreign Keys,Make Relation Name Unique and Merge Schemas check boxes.
- Click Save.
- In the Source field, select SQL Server in the migration toolkit.
- In the Destination field, select Db2 in the migration toolkit.
- Select all the tables in the chosen schema.
- Click Submit to migrate the data from the selected tables.
- Repeat the steps 12 and 13 for the CONFIG, RICALM, RIDW, and RIODS schemas.
- Re-create the triggers.
- Place createAllTriggers114.sql file in SQLLIB\BIN folder.
- Run this file from Db2 Command Window by using the following code:
db2 -td@ -vf C:\IBM\SQLLIB\BIN\createAllTriggers114.sql
- Enable the foreign key constraints in all data warehouse tables in the Db2 database. Save
the following script in enableFKConstraints.sql file in
SQLLIB\BIN folder:
BEGIN FOR v_row AS SELECT TABSCHEMA, TABNAME, CONSTNAME FROM SYSCAT.TABCONST WHERE TABSCHEMA IN ('CONFIG','RICALM','RIDW','RIODS') AND TYPE = 'F' DO EXECUTE IMMEDIATE 'ALTER TABLE ' || v_row.TABSCHEMA || '.' || v_row.TABNAME || ' ALTER FOREIGN KEY ' || v_row.CONSTNAME || ' ENFORCED'; END FOR; END@
- Run the following command in Db2 Command Window:
db2 -td@ -vf C:\IBM\SQLLIB\BIN\enableFKConstraints.sql
- After the migration is successful, update the stats for all DW tables by using following
command:
RUNSTATS ON TABLE TableName
- To compare the number of rows for all the tables for Source and Target databases, run the
following queries: Query for SQL Server
SELECT SCHEMA_NAME(sOBJ.schema_id) + '.' + sOBJ.name AS [TableNameSQLServer] , SUM(sPTN.Rows) AS [RowCountSQLServer] FROM sys.objects AS sOBJ INNER JOIN sys.partitions AS sPTN ON sOBJ.object_id = sPTN.object_id WHERE sOBJ.is_ms_shipped = 0x0 AND index_id < 2 AND sOBJ.type = 'U' AND SCHEMA_NAME(sOBJ.schema_id) IN ('CONFIG','RICALM','RIDW','RIODS') GROUP BY sOBJ.schema_id , sOBJ.name ORDER BY [RowCountSQLServer] DESC;
Query for Db2SELECT TRIM(TABSCHEMA) || '.' || TRIM(TABNAME) AS db2TableName, CARD AS db2RowNum FROM SYSCAT.TABLES WHERE TABSCHEMA IN ('CONFIG','RICALM','RIDW','RIODS') AND TYPE='T' ORDER BY CARD DESC;
- Update the data source properties for the data warehouse with the new Db2 database.
- Refresh the meta model for the data warehouse.
- Reimport the reports by selecting Import ready-to-use reports.
- Run and verify the existing data warehouse reports.
For troubleshooting the issues experienced during data migration, see Troubleshooting data migration from SQL Server to Db2.