[quoted text, click to view] On Oct 29, 8:33 am, stainless <Mark.Wingfi...@gmail.com> wrote:
> I am writing a package that is dynamic based on a parameter passed in
> via the DTSRUN command.
>
> This needs to do the following, where the package parameter amend the
> global parameter DataType before execution :
>
> Loop until end of files:
>
> Read 1st file in folder of name DataType (sequence number)
> If unexpected sequence
> Fail
> else
> Unload data from file into SQL table (different table
> and columns for each DataType)
> Move file to Completed folder
> Next file
> end
>
> I am happy with most of this except how to define the destination
> table and the transformation required for the data. This clearly needs
> to be either a dynamic step that involves defining the transformation/
> destination in some other code (how???) or a finite number of
> conditional steps with each potential transformation/destination in
> each step, thus the execution path will be different for each
> DataType.
>
> Any ideas/examples (particularly examples :))?
>
> Cheers
>
> Mark
Hi Mark,
Are you using SSIS (SQL 2005) or DTS (SQL 2000)? Based on your
description, I would assume it's SSIS and in this case you will need
to create a separate destination (and file source) for each datatype -
unless the files and tables have the same metadata (i.e. column
structure).
If the metadata is the same, you can set the source and destination
tasks dynamically quite easily. You should just need to put the table
name in a variable, and then in the destination task, select "Table or
view from variable". For the source you need to set the file
connectionstring dynamically using expressions.
In DTS it is possible to re-use the same source and destination
connections for tables with different metadata by changing your
connections and then dropping and recreating the datapump task at
runtime. This requires some familiarity with ActiveX scripting,
although writing the looping mechanism in DTS will probably cause you
more headaches than making the datapump dynamic ;)
Good luck!
J