Friday, March 25, 2005

Looping Through the Steps

Writing Active Script in VB to loop through the steps in DTS

Scenario :
Transfer of data from one database to another database across the network using DTS.
The amount of data to be transfered is huge, so while transfering data - Connection might be
lost, Data transfer error, Data Transform error etc., might appear
So transfer 1000 records, commit the transaction, loop through another set of 1000 records.
Continue this until all the records are transfered.

Steps :
1. Setup the Connection between two database.
2. Select 1000 records from Source database [This is DataPumpTask]
SELECT TOP 1000 * FROM [SOURCE_TABLE]
3. Copy the selected records to destination using DTS
4. Write a Active X Script to Check any more records are present in Source
SELECT COUNT(*) FROM [SOURCE_TABLE]
5. IF Count is greater than zero, continue from Step 2, DataPumpTask, till no more records are
found to transfer

Here is the code to loop through the steps

SET Pacakage = DTSGlobalVariables.Parent
SET StpBegin = Pacakage.Steps["DTSStep_DTSDataPumpTask_1"]
StpBegin.ExecutionStatus = DTSStepExecStat_Waiting

No comments: