Script component as a Transformation
Hi I have a table as follow:
ID CODE
1 100,200,300,400,500
2 111,222,333
3 11,22,33,44
And, I want the following outcome:
ID CODE
1^100
1^200
1^300
1^400
1^500
2^111
2^222
2^333
3^11
3^22
3^33
3^44
I am aboe to split the CODE into different rows by using Script Component as Transformation.
But i am getting something like this in flat file (carrot delimiters)
1^100
1^200
1
^300
1^400
1^500
2^111
2
^222
2^333
3^11
3^22
3
^33
3^44
Somehow, some CODES are going to the next line.
When i copy and pasted the codes onto to a notepad, it actually goes to the next line which is reflecting in my outcome'
Notepad comes like this:
For ID 1, it comes like:
100,200,
300,400,500
For ID 2:
111,
222,333
For ID 3:
11,22,
33,44
I used derived column after script component in my package to prevent the codes going to the next line but couldnt succeeded.
Please give some suggestions to solve this issue.
Thanks
May 2nd, 2012 6:21pm
How do you split each line? Something like Row.Code.Split(",")? For each item, try the Trim() method in your code.
http://www.linkedin.com/groupAnswers?viewQuestionAndAnswers=&discussionID=111924789&gid=54395&trk=eml-anet_dig-b_jb-ttl-cn&ut=1xtvtTYFyVMlc1Russel Loski, MCT, MCITP Business Intelligence Developer and Database Developer 2008 Blog: http://www.bidn.com/blogs/RussLoski/ Twitter: @sqlmovers
Free Windows Admin Tool Kit Click here and download it now
May 2nd, 2012 7:01pm
You should use a Derived Column before the script. There's special character in the CODE column, probably a CR or LF. Use REPLACE to replace it with nothing, like:
REPLACE(REPLACE([CODE], "\r", ""), "\n", "")
Talk to me now on
May 2nd, 2012 7:06pm
Awesome Todd. It Works. Thanks
Free Windows Admin Tool Kit Click here and download it now
May 2nd, 2012 7:19pm


