how to trim each and every colum without using dervied colum..i mean like creating a component or script task to trim all the incoming records
Pragmatic Works has a component in their Task Factory that does this.
It's difficult to do in a script component because the script intentionally obfuscates the collection of input columns. It's easy to do in a custom component... but custom components aren't easy to build up to the point where you can add that code.
Talk to me now on
April 20th, 2012 12:29am
You could do something with reflection in .Net:
http://microsoft-ssis.blogspot.com/2010/12/do-something-for-all-columns-in-your.html
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
foreach (PropertyInfo p in Row.GetType().GetProperties())
{
if (object.ReferenceEquals(p.PropertyType, typeof(string)))
{
try
{
p.SetValue(Row, DoSomething(p.GetValue(Row, null).ToString()), null);
}
catch
{
}
}
}
}
public string DoSomething( string ValueOfProperty)
{
// do something: upper/replace/trim/etc
ValueOfProperty = ValueOfProperty.Replace(";", ",").Replace("\"", "'").Replace("\t" ,"");
return ValueOfProperty;
}
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com |
Twitter
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2012 9:32am
You could do something with reflection in .Net:
http://microsoft-ssis.blogspot.com/2010/12/do-something-for-all-columns-in-your.html
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
foreach (PropertyInfo p in Row.GetType().GetProperties())
{
if (object.ReferenceEquals(p.PropertyType, typeof(string)))
{
try
{
p.SetValue(Row, DoSomething(p.GetValue(Row, null).ToString()), null);
}
catch
{
}
}
}
}
public string DoSomething( string ValueOfProperty)
{
// do something: upper/replace/trim/etc
ValueOfProperty = ValueOfProperty.Replace(";", ",").Replace("\"", "'").Replace("\t" ,"");
return ValueOfProperty;
}
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com |
Twitter
April 20th, 2012 9:32am
how to trim each and every colum without using dervied colum..i mean like creating a component or script task to trim all the incoming recordsilikemicrosoft
Free Windows Admin Tool Kit Click here and download it now
April 21st, 2012 8:16am
http://stackoverflow.com/questions/3838228/trim-before-destination-write-in-ssisBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
April 21st, 2012 8:52am
Use script transformation.add input and output columns.
declare some variables within script named c1,c2....
assign values to variables like this- c1 = Trim(Row.Column0)
c2 = Trim(Row.Column1)
after this assign these variable values to script component output columns-
Me.Output1Buffer.AddRow()
Me.Output1Buffer.Column1 = c1
Me.Output1Buffer.Column2 = c2
Thanks,
Tanmoy
Free Windows Admin Tool Kit Click here and download it now
April 21st, 2012 10:39am
Pragmatic Works has a component in their Task Factory that does this.
It's difficult to do in a script component because the script intentionally obfuscates the collection of input columns. It's easy to do in a custom component... but custom components aren't easy to build up to the point where you can add that code.
Talk to me now on
April 21st, 2012 5:36pm
I've used the System.Reflection namespace technique successfully to loop through the input columns. Here's a reasonable example:
http://www.bidn.com/blogs/MikeDavis/ssis/1800/ssis-for-each-column-in-a-data-flow
Just change the line starting StrCol = ... to something like this:
strCol = strCol.Trim()
Good luck!
Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2012 1:58am
You could do something with reflection in .Net:
http://microsoft-ssis.blogspot.com/2010/12/do-something-for-all-columns-in-your.htmlPlease mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com |
Twitter
April 22nd, 2012 2:38am