I am importing a flat file with the following format:
H(tab)OrderNumber(tab)CustomerNumber(tab)ERPMessage
D(tab)OrderNumber(tab)ItemNumber(tab)ItemDescription(tab)ItemPrice(tab)Qty
D(tab)OrderNumber(tab)ItemNumber(tab)ItemDescription(tab)ItemPrice(tab)Qty
.
.
.
I am BULK LOADing the file using a format file to a staging table that looks like this:
RecordType varchar(1)
RecordDetail varchar(MAX)
so when it hits my staging table, it looks like this:
RecordType | RecordDetail
----------------------------------------------------------
H | OrderNumber(tab)CustomerNumber(tab)ERPMessage
D | OrderNumber(tab)ItemNumber(tab)ItemDescription(tab)ItemPrice(tab)Qty
D | OrderNumber(tab)ItemNumber(tab)ItemDescription(tab)ItemPrice(tab)Qty
In my control flow, I set a variable (strSubfolder) based on the name of the subfolder the file is loaded from in my ForEach loop (ie: Sub_1, Sub_2, etc).
In my data task, I read the staging table and peform a conditional split based on the RecordType, and creating derived columns based on the strSubfolder variable. What I need to be able to do is parse The RecordDetail field into its respective Header (H) and Detail(D) tables, and include the strSubfolder as a derived column to each table:
[Header table]
OrderNumber | SubFolder | CustomerNumber | ERPMessage
-----------------------------------------------------
[Detail table]
OrderNumber | SubFolder | ItemNumber | ItemDescription | ItemPrice | Qty
------------------------------------------------------------------------
How do I parse the RecordDetail field of my staging table, essentially treating it like its own BULK INSERT? Am I going about this in the entirely wrong way?