Strip carriage return from varchar2 column

January 8th, 2010 Posted in Oracle How-To, Oracle Tip

Have you ever needed to strip a carriage return from varchar2 column? Sometime when loading data from different sources I run into these non-printable characters. SQLLDR loaded them just fine, but I try to move the data into another table with specific datatypes it fails. Why? Because there are character that I cannot see and will not allow the varchar2 data to insert into a number column.

The fix is pretty simple. Run this update:

update staging_table1 set duration = replace(duration,chr(13),'');

Leave a Reply