Manage Learn to apply best practices and optimize your operations.

How to find carriage returns in data

CARRIAGE RETURNS basically screw up records and create problems while processing them. Here's how to find them.

There are instances when users mistakenly enter a carriage return -- while entering an address, for example. This...

basically screws up the record and creates problems while processing it. One of the problems that can happen is that part of the address field (or any other field) in which the user has entered a carriage return will end up as data for some other field.

Here's how to deal with this problem. I save this script as CR.sql and run it at the SQL prompt. I have one record in my table which has carriage return in the ADDR1 field. This is what it looks like:


ACCTID           ADDR1                          INSTR(ADDR1,CHR(13)) 
---------------- ------------------------------ -------------------- 
ADDR2                          INSTR(ADDR2,CHR(13)) 
------------------------------ -------------------- 
emorial Pky      450 Veterans      14 
Typ=1 Len=25: 52,53,48,32,86,101,116,101,114,97,110,115,32,13,101,109,111,114,10 


Here is the the code for CR.sql:

set pages 100 arraysize 1 
select distinct acctid,addr1,instr(addr1,chr(13)),dump(addr1)   dumpaddr1,addr2, 
instr(addr2,chr(13)), dump(addr2)  dumpaddr2 
from org 
where instr(addr1,chr(13))!=0 

For More Information

  • What do you think about this tip? E-mail the Editor at with your feedback.
  • The Best Oracle Web Links: tips, tutorials, scripts, and more.
  • Have an Oracle tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
  • Ask your technical Oracle questions--or help out your peers by answering them--in our live discussion forums.
  • Check out our Ask the Experts feature: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.

This was last published in April 2002

Dig Deeper on Oracle and SQL

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.