dbTalk Databases Forums  

Generic DTS package

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Generic DTS package in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alex
 
Posts: n/a

Default Generic DTS package - 06-09-2004 , 10:48 AM






Any help would be much appreciated!!

I am creating a generic DTS package that will export data from SQL to
Access on a daily basis. All one would do is change the database names
etc stored in global variables and run the package. The steps I have
are as follows:

1) Select table names in the SQL DB and set the rowset to a global
variable
2) Loop through each table in that rowset and pump the data into the
equivalent access table

The data pump is however not working. The first table pumps the data
fine, but when it reaches the second table in the loop it crashes as
the transformation is still looking at the first table columns. I
somehow need to set this dynamically.I have read a couple of messages
posted and it appears you have to write a script that will set the
source and destination items for each pump. What I did was set the
workflow properties of the Transform Data task to the code found on
ssqldts.com:

Dim oPkg, oDataPump
Dim sSourceTable, sDestinationTable

' Derive the new table names
sSourceTable = DTSGlobalVariables("gvSourceTable")
sDestinationTable = DTSGlobalVariables("gvDesTable")

' Get reference to the DataPump Task
Set oPkg = DTSGlobalVariables.Parent
Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask

' Set the new values
oDataPump.SourceObjectName = sSourceTable
oDataPump.DestinationObjectName = sDestinationTable

' Clean Up
Set oDataPump = Nothing
Set oPkg = Nothing

Main = DTSStepScriptResult_ExecuteTask

It still does not work. How would I create a new transformation for
each table and make it auto map. The table names in SQL are the same
as the Access DB.

Please Help!!

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Generic DTS package - 06-09-2004 , 10:57 AM






Ok yes you do.

You not only need to change the connection properties but you will need to
remove all Transformation objects and then add them back again using the
metadata from your tables.

I have an example of doing this using a Query going to an Ecel spredsheet so
you could edit this and then loop through your recordset. It should be
doable so long as the destination columns match the source columns.

mail me privately if you want a look.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Alex" <tigermine13 (AT) hotmail (DOT) com> wrote

Quote:
Any help would be much appreciated!!

I am creating a generic DTS package that will export data from SQL to
Access on a daily basis. All one would do is change the database names
etc stored in global variables and run the package. The steps I have
are as follows:

1) Select table names in the SQL DB and set the rowset to a global
variable
2) Loop through each table in that rowset and pump the data into the
equivalent access table

The data pump is however not working. The first table pumps the data
fine, but when it reaches the second table in the loop it crashes as
the transformation is still looking at the first table columns. I
somehow need to set this dynamically.I have read a couple of messages
posted and it appears you have to write a script that will set the
source and destination items for each pump. What I did was set the
workflow properties of the Transform Data task to the code found on
ssqldts.com:

Dim oPkg, oDataPump
Dim sSourceTable, sDestinationTable

' Derive the new table names
sSourceTable = DTSGlobalVariables("gvSourceTable")
sDestinationTable = DTSGlobalVariables("gvDesTable")

' Get reference to the DataPump Task
Set oPkg = DTSGlobalVariables.Parent
Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask

' Set the new values
oDataPump.SourceObjectName = sSourceTable
oDataPump.DestinationObjectName = sDestinationTable

' Clean Up
Set oDataPump = Nothing
Set oPkg = Nothing

Main = DTSStepScriptResult_ExecuteTask

It still does not work. How would I create a new transformation for
each table and make it auto map. The table names in SQL are the same
as the Access DB.

Please Help!!



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.