Page 1 of 1

remove carriage return

Posted: Thu Apr 14, 2005 2:23 am
by sun786
Hi all,

Ther is a carriage returns in the text of one of string fields in a coloumn.

Eg: PAY SLIP is the value of a field. SLIP is going to the next row as there
is a carriage retrun after PAY.

I need to remove this carriage return from the feild.

Please help.

Regards
Siraz.

Posted: Thu Apr 14, 2005 2:36 am
by ray.wurlod

Code: Select all

Convert(Char(10):Char(13),"",InLink.ColumnName)
Even though you're on UNIX, removing CR as well as LF is not a bad move, since the original source could have been a DOS file. If it wasn't then there aren't any CR characters, so there's no harm done.

Posted: Thu Apr 14, 2005 2:38 am
by StefL
You might be able to use the CONVERT function, like I've recently done but in the 'opposite' direction (I wanted to convert comma to line feed).
Since CR is not a character you can type into a derivation field you also need to use the CHAR function and feed it with the ASCII number for CR (13).

So try writing CONVERT(Char(13),"",<in_string>) where <in_string> is the string that contains CR. I assume you just want to remove CR, hence the empty string "", else just put anything you want to replace CR with between the quotes.

Posted: Thu Apr 14, 2005 2:47 am
by sun786
how abt using Ereplace function?

Posted: Thu Apr 14, 2005 10:10 am
by MaheshKumar Sugunaraj
Yes you could use Ereplace as well,

Ereplace(ColumnName,Char(13),"")

Thanks & Regards
Mahesh

Posted: Thu Apr 14, 2005 3:04 pm
by ray.wurlod
EREPLACE is less efficient than CONVERT where appropriate to use it.

CONVERT performs character-by-character conversion.
EREPLACE replaces one substring with another.

You can use CONVERT to replace single characters with other single characters, including "".
However, if you want to replace one or more characters with more than one character, you need to use EREPLACE.