AllPower
AllPower

Reputation: 195

ORACLE - Remove line breaks from a text field

When I extract the txt field from database, it's bringing the text with the line breaks and it's misconfiguring when I export to excel

There is a way to leave all the text on one line and not bring these line breaks

Example?

Currently:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

how i would like, eveything in 1 line

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ....

Upvotes: 0

Views: 3322

Answers (2)

Littlefoot
Littlefoot

Reputation: 142720

REPLACE:

SQL> select text from test;

TEXT
---------------------------------------
Lorem ipsum
dolor sit amet,
consectetur


SQL> select replace(text, chr(10), '') new_text
  2  from test;

NEW_TEXT
---------------------------------------
Lorem ipsumdolor sit amet,consectetur

SQL>

Upvotes: 1

Matt
Matt

Reputation: 15061

You can use the TRANSLATE function.

SELECT TRANSLATE(txt_field, 'x'||CHR(10)||CHR(13), 'x')
FROM yourtable

Upvotes: 0

Related Questions