2017-09-20 64 views
0
  1. 我有表,該表由幾個標題代碼標題代碼讀取文本文件塊(它總是與HDR開始)
  2. 每頭將擁有自己的BHD(開始)和BTR (結束)標籤

I需要爲每個塊添加相應的標題值作爲新列。如何通過基於塊的在SSIS

樣品表:

HDR20170101 
BHD0000A123J010203 
0020CHETRI  || ULTRA DELUXE || 123UD || 00:20 
0300CHETRIKK02S || DELUXE  || 908UU || 03:00 
0330CHETRIKK02S || DELUXE  || 908BN || 03:30 
BTR0000A123J010203DHU84596 
HDR20170102 
BHD0000A123J010225 
0400CHETRIKK02O || ORDINARY  || 908AH || 04:00 
0400CHETRIKK02S || DELUXE  || 908BN || 04:00 
0500CHETRIKK02O || ORDINARY  || 908AC || 05:00 
0515CHETRIKK02S || DELUXE  || 908AE || 05:15 
BTR0000A123J010225DHU59658 
HDR20170103 
BHD0000A123J010242 
0530CHETRIKK04O || ORDINARY  || 2251 || 05:30 
0615CHETRIKK02S || DELUXE  || 908BC || 06:15 
BTR0000A123J0100242DHU34745 

預期輸出:

Trip Code  || ClassOfServ || Route || Depart || Header 
0020CHETRI  || ULTRA DELUXE || 123UD || 00:20 || HDR20170101 
0300CHETRIKK02S || DELUXE  || 908UU || 03:00 || HDR20170101 
0330CHETRIKK02S || DELUXE  || 908BN || 03:30 || HDR20170101 
0400CHETRIKK02O || ORDINARY  || 908AH || 04:00 || HDR20170102 
0400CHETRIKK02S || DELUXE  || 908BN || 04:00 || HDR20170102 
0500CHETRIKK02O || ORDINARY  || 908AC || 05:00 || HDR20170102 
0515CHETRIKK02S || DELUXE  || 908AE || 05:15 || HDR20170102 
0530CHETRIKK04O || ORDINARY  || 2251 || 05:30 || HDR20170103 
0615CHETRIKK02S || DELUXE  || 908BC || 06:15 || HDR20170103 

回答

0

這將需要的腳本。

您可以編寫完成整個任務的腳本任務,也可以創建使用腳本組件作爲源的數據流。使用filesystemobject打開filestream並逐行讀取文件,並分析每行以查看它是HDR,BHD,BTR還是常規數據行。將最後的HDR值保留在局部變量中,並將其作爲附加列添加到每個數據行。