Page 1 of 1

Converting CR and LF to Empty stirng

Posted: Sat Aug 27, 2011 3:31 am
by mac4rfree85
Hi Guys,

I like to convert CR and LF which is coming in a particular column to Empty string.

I tried the following but it was not converted.

Code: Select all

Convert('chr(10)chr(13)','',COLNAME)
Can somebody help me with this.

Cheers!!!

Posted: Sat Aug 27, 2011 6:16 am
by Ravi.K
Try using below derivation.

Covert(char(13),'',Convert(char(10),'',COLNAME))

Re: Converting CR and LF to Empty stirng

Posted: Sat Aug 27, 2011 7:38 am
by chulett
mac4rfree85 wrote:I tried the following but it was not converted.
You quoted the char functions you were attempting to use so they just turned into a 14 character string.

Posted: Sat Aug 27, 2011 4:30 pm
by ray.wurlod
You also used incorrect function names, and did not concatenate them.

The correct equivalent for your expression is

Code: Select all

Convert(Char(10) : Char(13), "", InLink.COLNAME)
However there is a cost in evaluating the Char() function. More efficient would be to create a stage variable, let's call it svCRLF, initialized to Char(13) : Char(10), and not given a derivation for each row. Then the expression becomes

Code: Select all

Convert(svCRLF, "", InLink.COLNAME)

Posted: Mon Aug 29, 2011 3:36 am
by mac4rfree85
Yeah Ray, i found it later.. thanks anyway.. :)