I’ve created with the help of some great people an SSIS 2005 package which does the follow so far:
1) Takes an incoming txt file. Example txt file: http://www.webfound.net/split.txt
The txt file going from top to bottom is sort of grouped like this
Header Row (designated by ‘HD’)
Corresponding Detail Rows for the Header Row
…..
Next Header Row
Corresponding Detail Rows
…and so on
http:
2) Header Rows are split into one table, Maintenance Detail Rows into another, and Payment Detail Rows into a third table. A uniqueID has been created for each header and it’s related detail rows to form a PK/FK relationship as there was non prior to the import, only the relation was in order of header / related rows below it when we first started. The reason I split this out is so I can massage it later with stored proc filters, whatever…
Now I’m trying to somehow bring back the data in those table together like it was initially using a query so that I can cut out each of the Header / Detail Row sections into their own txt file. So, if you look at the original txt file, each new header and it’s related detail rows (example of a cut piece would be http:
This is where I’m stuck. How to create a query to combine it all back into an OLE DB Souce component, then somehow read that souce and split out the sections into their own individual txt files.
The filenames of the txt files will vary and be based on one of the column values already in the header table.
Here is a print screen of my package so far:
http://www.webfound.net/tasks.jpg
http://www.webfound.net/Import_MaintenanceFile_Task_components.jpg
http://www.webfound.net/DataFlow_Task_components.jpg
Let me know if you need more info. Examples of the actual data in the tables are here:
http:
http:
http:
Here's a print screen of the table schema:
http://www.webfound.net/schema.jpg

Combine Data and Split into separate txt files for each header/detail row groupings
EricEarle
I sort of did a sketch of what I think might work but really I don't know if I'm using the right components here or how to set this up. Basically, I want to bring back in the records like in the txt file...then split out each header and it's corresponding detail rows to a separate txt file
this is just a sketch...I'm a bit helpless at this point.
http://www.webfound.net/try2.jpg
so for example, one section cut out into a txt file would look liek this in the new txt file:
http://www.webfound.net/rows.jpg
I have no clue how to accomplish all this but first trying to combine my data back into a format like the original txt file based on the PK/FK relationship I setup using mnt_HeaderID
DaveM.
Yeah, that makes sense.
Basically, if the tables have different metadata then you can't process them in the same data-path. This does not mean that you can't process them in the same data-FLOW if that's what you want.
-Jamie
Ed Pinto - MSFT
Ok, I'm thinking something like this But isn't this UNION just gonna do the same thing....give me the HeaderRows first, then Maintenance, then Payment rows instead of grouping them like I want:
http://www.webfound.net/try1.jpg
Ultimately what I'm gonna be doing is creating individual TXTs for each header grouping then in the end I'll have to take those txts and based on a field I created from my table...or the txt name, do a loop and move them to specific directories (using UNC to our server) by changing the UNC path dynamically based off a lookup table...all this is comlicated.
dX10
HK.Lee
one more try on explaining what i want to do. It looks like to me tryign to combine the fields in SQL isn't gonna work using UNION so maybe I can just use 3 pipelines in SSiS then split.
So...with that said, lets start over. Now how can I take the 3 pipelines and split into separate txt files for each header / detail row group combination.
http://www.webfound.net/3tables.jpg
example data from each table:
http://www.webfound.net/mnt_headerRows.txt (header table)//www.webfound.net/mnt_MaintenanceRows.txt (maitnenancerows table)//www.webfound.net/mnt_PaymentRows.txt (paymentrows table)
http:
http:
Desired outcome based on match of a Unique key field I created in all 3 tables, PK/FK relationship between each header row and it's detail rows in the other 2 tables
(example of desired txt file creation):
http://www.webfound.net/desired2.txt
so there will be many txts created based on each header in short
Manish_Jain
or try to do the same using my view, which does the proper UNION that I"m trying to fix then create the separate txt files somehow for each grouping:
http://www.webfound.net/try3.jpg
Dylan Morley
Glenn Wilson
guysky
the biggest problem I have doing the union is that the rows between the 3 tables start out the same but after a few initial fields, have drasticall different # of columns, length of fields, and possibly in the future those datatypes may change behind the columns. Right now, yes, they're all varchar but drastically different in # cols and # chars
i can try to use placement fillers like ' ',
but that is maybe not possible as they are so drastically different from one another. I am trying but it's tricky, I have to look and compare all 3 tables to figure out where to put the ' ', and still not sure if in the end that will be possible.
Marlon_Casusol
If you're combining data from multiple tables then you probably need to UNION it. It must have the same metadata of course. You can do this in the source component or using a UNION ALL transform in the pipeline.
To split into seperate files, use the conditional split transform. You'll need a column indicating which dataset the row belongs to in roder to split it all up.
Can I ask why you're staging to tables in the interim Is this a requirement
-Jamie
Noam
If the metadata of the 3 tables is different then UNIONing them, either in the pipeline or in T-SQL isn't an option. You need 3 seperate loads.
When I said it could all be in the same data-flow I meant as 3 completely seperate data-paths - that's effectively the same as 3 seperate data-flows. The only difference is that performance can be a bit better. Sorry if I confused you over that.
-Jamie
spert
Jamie, sorry, can you explain how I'd accomplish this in a data flow then that's what I'm not sure of. If I can't use SQL then yea, SSIS would be another option
Ravimcom
shart44
I want this
header
related maintenance and payment rows (relation is based on mnt_HeaderID)
header
related maintenance and payment rows (relation is based on mnt_HeaderID)
header
related maintenance and payment rows (relation is based on mnt_HeaderID)
header
related maintenance and payment rows (relation is based on mnt_HeaderID)
just like the original txt file.
How do I form my SQL to do this
So my current SQL is:
SELECT h.mnt_HeaderID as hdr_HeaderID,
h.BatchDate +
h.NotUsed +
h.TransactionCode +
h.GrossBatchTotal +
h.NetBatchTotal +
h.BatchTransactionCount +
h.PNet_ID +
h.PartnerCode +
h.Filler as HeaderRow,
h.PNet_ID as FilePath
FROM mnt_Header h
UNION ALL
(SELECT m.mnt_HeaderID as mnt_HeaderID,
m.TransactionDate +
m.TransactionTime +
m.AccountNumber +
m.TransactionCode +
m.FieldCode +
m.NewValue +
m.InternalExternalFlag +
m.PNetID +
m.RecovererID +
m.LoanCode +
m.NotUsed as mnt_Row,
' '
FROM mnt_MaintenanceRows m)
UNION ALL
(SELECT p.mnt_HeaderID as pmt_HeaderID,
p.TransactionDate +
p.TransactionTime +
p.AccountNumber +
p.TransactionCode +
p.TransactionAmount +
p.InterestFlag +
p.SelfDirectedFlag +
p.TransactionDesc +
p.NetPaymentAmount +
p.CommissionPercent +
p.InternalExternalFlag +
p.PNetID +
p.RecovererID +
p.RMSLoanCode +
p.Filler as pmt_Row,
' '
FROM mnt_PaymentRows p)
output I'm getting now is:
http: