2011-10-25 85 views
0

我是新來的SSIS,所以任何幫助,建議,諮詢和指導,我將非常感激抽一個平面文件目標數據。謝謝。使用SSIS,如何安排在正從OLE DB源

場景

我想DTS包轉換爲SSIS包。我的軟件包包含一個數據流任務,可將數據從OLE DB連接泵送到平面文件目標。

的問題

平面文件中的數據需要被安排在以某種方式(如:間距),那麼,我該怎麼辦?有沒有任何數據轉換工具可以幫助我實現這一目標?如果是這樣怎麼辦?

THE DTS CODE(在透視放東西)

* ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** 'Visual Basic中的ActiveX腳本 ' ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * **

DO WHILE NOT rsGetActivations.eof OR rsGetActivations.BOF 
    sLineItem = Space(10) 
    sLineItem = sLineItem & Space(10) 
    sLineItem = sLineItem & Space(10) 
    sLineItem = sLineItem & Replace(Space(8)," ","0") 
    sLineItem = sLineItem & Space(1) 
    sLineItem = sLineItem & Replace(Space(8)," ","0") 
    sLineItem = sLineItem & Replace(Space(3)," ","0") 
    sLineItem = sLineItem & Space(2) 
    sLineItem = sLineItem & rsGetActivations("Data_Date") & Space(8 - Len( rsGetActivations("Data_Date"))) 
    sLineItem = sLineItem & rsGetActivations("ID_Number") & Space(16 - Len( rsGetActivations("ID_Number"))) 
    sLineItem = sLineItem & Space(4) 
    sLineItem = sLineItem & rsGetActivations("Main_Name") & Space(25 - Len( rsGetActivations("Main_Name"))) 
    sLineItem = sLineItem & rsGetActivations("First_Name") & Space(15 - Len( rsGetActivations("First_Name"))) 
    sLineItem = sLineItem & rsGetActivations("Middle_Name") & Space(15 - Len( rsGetActivations("Middle_Name"))) 
    sLineItem = sLineItem & rsGetActivations("Third_Name") & Space(15 - Len( rsGetActivations("Third_Name"))) 
    sLineItem = sLineItem & rsGetActivations("DOB") & Space(8 - Len( rsGetActivations("DOB"))) 
    sLineItem = sLineItem & rsGetActivations("ID_Number") & Space(13 - Len( rsGetActivations("ID_Number"))) 
    sLineItem = sLineItem & rsGetActivations("Non_RSA_ID") & Space(16 - Len( rsGetActivations("Non_RSA_ID"))) 
    sLineItem = sLineItem & Space(15) 
    sLineItem = sLineItem & Space(15) 
    sLineItem = sLineItem & Space(15) 
    sLineItem = sLineItem & Space(15) 
    sLineItem = sLineItem & rsGetActivations("Gender") & Space(1 - Len( rsGetActivations("Gender"))) 
    sLineItem = sLineItem & Space(3) 
    sLineItem = sLineItem & Space(1) 
    sLineItem = sLineItem & Space(15) 
    sLineItem = sLineItem & Space(15) 
    sLineItem = sLineItem & Space(40) 
    sLineItem = sLineItem & "0" 
    sLineItem = sLineItem & rsGetActivations("Res_Line1") & Space(30 - Len( rsGetActivations("Res_Line1"))) 
    sLineItem = sLineItem & rsGetActivations("Res_Line2") & Space(30 - Len( rsGetActivations("Res_Line2"))) 
    sLineItem = sLineItem & rsGetActivations("Res_Line3") & Space(30 - Len( rsGetActivations("Res_Line3"))) 
    sLineItem = sLineItem & rsGetActivations("Res_Line4") & Space(30 - Len( rsGetActivations("Res_Line4"))) 
    sLineItem = sLineItem & rsGetActivations("Res_Postal") & Space(6 - Len( rsGetActivations("Res_Postal"))) 
    sLineItem = sLineItem & Space(1) 
    sLineItem = sLineItem & "00" 
    sLineItem = sLineItem & Space(1) 
    sLineItem = sLineItem & rsGetActivations("Post_Line1") & Space(30 - Len( rsGetActivations("Post_Line1"))) 
    sLineItem = sLineItem & rsGetActivations("Post_Line2") & Space(30 - Len( rsGetActivations("Post_Line2"))) 
    sLineItem = sLineItem & rsGetActivations("Post_Line3") & Space(30 - Len( rsGetActivations("Post_Line3"))) 
    sLineItem = sLineItem & rsGetActivations("Post_Line4") & Space(30 - Len( rsGetActivations("Post_Line4"))) 
    sLineItem = sLineItem & rsGetActivations("Post_Postal") & Space(6 - Len( rsGetActivations("Post_Postal")))  
    sLineItem = sLineItem & Space(1) 
    sLineItem = sLineItem & "00" 
    sLineItem = sLineItem & rsGetActivations("Bank_Name") & Space(20 - Len( rsGetActivations("Bank_Name"))) 
    sLineItem = sLineItem & rsGetActivations("Bank_Branch") & Space(20 - Len( rsGetActivations("Bank_Branch"))) 
    sLineItem = sLineItem & Space(6 - Len( rsGetActivations("Branch_No"))) & rsGetActivations("Branch_No") 
    sLineItem = sLineItem & Space(15 - Len( rsGetActivations("Account_No"))) & rsGetActivations("Account_No") 
    sLineItem = sLineItem & rsGetActivations("Home_Code") & Space(11 - Len( rsGetActivations("Home_Code"))) 
    sLineItem = sLineItem & rsGetActivations("Home_Tel") & Space(15 - Len( rsGetActivations("Home_Tel"))) 
    sLineItem = sLineItem & rsGetActivations("Work_Code") & Space(11 - Len( rsGetActivations("Work_Code"))) 
    sLineItem = sLineItem & rsGetActivations("Work_Tel") & Space(15 - Len( rsGetActivations("Work_Tel"))) 
    sLineItem = sLineItem & rsGetActivations("Cell_No") & Space(10 - Len( rsGetActivations("Cell_No"))) 
    sLineItem = sLineItem & Space(35) 
    sLineItem = sLineItem & rsGetActivations("Occupation") & Space(22 - Len( rsGetActivations("Occupation"))) 
    sLineItem = sLineItem & rsGetActivations("Emp_Name") & Space(35 - Len( rsGetActivations("Emp_Name")))  
    sLineItem = sLineItem & Space(2) 
    sLineItem = sLineItem & Space(6)   

    fExportFile.Write( sLineItem & sCRLF) 

    rsGetActivations.MoveNext 
LOOP'//end WHILE NOT rsGetActivations.eof OR rsGetActivations.BOF 

回答

0

我肯定不會錯過DTS ...

什麼你正在尋找因爲在SSIS中是一個平面文件連接管理器並指定它是固定寬度(在高級中定義列)。關於讓連接管理器確定大小美麗的東西是你設置一次,僅此而已,沒有關閉的情況的一個錯誤的輸出,因爲你flubbed邏輯。不是說我曾經做過

常規選項卡

Flat File Connection Manager - General tab

列選項卡

Flat File Connection Manager - columns tab

高級選項卡

Flat File Connection Manager - Advanced tab

的數據流會看起來像

enter image description here

我不知道是0填充列的唯一的事情。您可能需要使用派生列來填充這些列,但不應該太糟糕 - 只需填充零的列大小,並採用正確的N個字符以及通常的NULL連接規則即可保持警惕。

+0

再次感謝您的幫助。但是我收到一條錯誤消息,指出組件未處於有效狀態。當我點擊高級時,我的所有顏色消失。有很多顏色被泵浦,並且它們會自動填充高級桌子。那麼我該如何解決這個問題呢?有任何想法嗎? – HarshiRulz

+0

Gr8,非常感謝! – HarshiRulz