2011-03-14 63 views
0

我有一個平面文件,其結構是作爲一些問題,SSIS腳本組件代碼,SQL Server 2008中

Id Value 
1 1,2,3 
2 4,5 

輸出需求爲

ID Value 
1 1 
1 2 
1 3 
2 4 
2 5 

我有一個平面文件源和一個腳本組件被製作爲異步。而在腳本編輯器中我寫了下面的代碼

public override void Input0_ProcessInputRow(Input0Buffer Row) 
     { 
       MyOutputBuffer.AddRow(); 
       string[] arr = Row.Column1.Split(','); 
       foreach (string s in arr) 
       { 
       if (!string.IsNullOrEmpty(Row.Column0)) 
       { 
         MyOutputBuffer.ID = Row.Column0; 
         MyOutputBuffer.Values = s; 
         MyOutputBuffer.AddRow(); 
       } 
       }   
     } 
     public override void Input0_ProcessInput(Input0Buffer Buffer) 
     { 
      while (Buffer.NextRow()) 
      { 
       Input0_ProcessInputRow(Buffer); 
      } 

      if (Buffer.EndOfRowset()) 
      { 
       MyOutputBuffer.SetEndOfRowset(); 
      } 
     } 

但我得到下面的輸出

Id Value 
NULL NULL 
1 1 
1 2 
1 3 
NULL NULL 
2 4 
2 5 
NULL NULL 

什麼是錯的程序。

請幫

回答

1

得到了修復

public override void Input0_ProcessInputRow(Input0Buffer Row) 
    {  

     string[] arr = Row.Column1.Split(','); 
     foreach (string s in arr) 
     { 
      MyOutputBuffer.AddRow(); 
      if (!string.IsNullOrEmpty(Row.Column0)) 
      { 
       MyOutputBuffer.ID = Row.Column0; 
       MyOutputBuffer.Values = s; 

      } 
     } 
    } 
+1

你可能想繼續前進,將此作爲答案讓人們知道它,而無需打開回答。 :-) – DKnight 2011-03-14 18:12:55