开发者

some problem with SSIS script component code, Sql Server 2008

开发者 https://www.devze.com 2023-02-16 11:10 出处:网络
I have a flat file whose structure is as IdValue 11,2,3 24,5 The output needs to as IDValue 11 12 13 24 25 I have a flat file source and a script component which is being made as asynchronous.

I have a flat file whose structure is as

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

The output needs to as

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

I have a flat file source and a script component which is being made as asynchronous. And in the script editor I have written the below code

 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.NextR开发者_开发百科ow())
            {
                Input0_ProcessInputRow(Buffer);
            }

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

But I am getting the below output

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

What is wrong in the program.

Please help


Got the fix

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;

            }
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消