some problem with SSIS script component code, Sql Server 2008
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;
}
}
}
精彩评论