Hi Hans,
Within your loop, before you import the data, read the second line of the
text file and extract the ShopID number, e.g. 00093. (see below how to do
it). Save it in a global variable, then use it within a Data Transformation
ActiveX script. i.e. you have to create a new ActiveX mapping to the ShopID
destination column in your database, and use a line like this:
DTSDestination("ShopID") = DTSGlobalVariables("ShopID").Value
The other column mappings can stay as Copy Column mappings.
To obtain the ShopID from your file, here is a very simple ActiveX script
which assumes the ShopID is always on the second line before the first
semicolon. The script writes the ShopID to a global variable called ShopID
that you need to create in the package. This script must come before the data
pump task:
dim oFSO, oStream, strTextRead, position, myValue
set oFSO = CreateObject("Scripting.FileSystemObject")
set oStream = oFSO.OpenTextFile("c:\MyDataFile.txt", 1)
strTextRead = oStream.Readline
strTextRead = oStream.Readline
position = instr(strTextRead, ";") - 1
myValue = left(strTextRead, position)
DTSGlobalVarialbes("ShopID").Value = myValue
msgbox myValue
set oStream = Nothing
set oFSO = nothing
Note that in your case the file name will change for each loop iteration.
But I am assuming you have figured out how to do that part because you say
you have implemented a loop already. Use the global variable that contains
your file name in place of the hard-coded "c:\MyDataFile.txt" that I have put
here.
This should be very easy to implement.
Hope this helps.
Charles Kangai, MCT, MCDBA
[quoted text, click to view] "Hans Vergouwen" wrote:
> Hi everyone,
>
> Short introduction; I work for Biretco BV in the netherlands; we are a
> retail organisation for bicycle stores!
>
> Now the case is :
> Everyday we sell products in each store. (approx 500 shops)
> At night the shops upload their file on our FTP..
> I collect the files (there are 500shops x 1 file) about 500 files
> everyday
>
> All the files have the same format:
> HEADERRULE:
> 00093;Profile Rudie Assink;Raalte;20.07.06;2.0
>
> DATARULE:
> 20.07.06;08:55;29;0200006543;;2;Rudie;3020.0151;8712265014549;BAND
> PROFILE 3000
> BREAK;3020;Profile;3;5.30;15.95;1;13.40;15.95;13.40;15.95;0.00;0.00;8.10;60.5
>
> I have already created looping, importing and archiving according to
> article:
>
http://www.sqldts.com/default.aspx?246 >
> with this I mean all files are imported in my SQL table!
>
> The problem is that I cannot identify the rules in the SQL table ....
> what row belongs to which bicycle shop????
>
> To achieve this the header row's first column; (in my example : 00093)
> needs to be imported in every row in the sql server before starting
> with the next file!!
>
> Because I don't understand VB i cannot write my own activex
> transformation...
>
> I think it can be done by storing the first column in a variable... but
> how?
>
> thanks in advance!!!
>
> Hans Vergouwen
>