tags:

views:

196

answers:

5

I need to find the rows where a certain column contains line feed.

This does not work: select * from [table] where [column] like '%\n%'

In SO, I found the solution for SQL Server: http://stackoverflow.com/questions/1085662/new-line-in-sql-query

But this does not work in Oracle. Is there any ANSI SQL solution? This should be a standard...

If not, what is the solution in Oracle?

+3  A: 

Hi Bruno,

you could look for the CHR(10) character (the character for newline):

select * from [table] where instr(column, chr(10)) > 0
Vincent Malgrat
A: 

select * from tableNameHere where instr(colNameHere, chr(10)) > 0

dpbradley
A: 

Alternatively:

SELECT * FROM [table] WHERE column LIKE "%\n%"

\n is line feed, \r is carriage return...

tog22
@thomasnash - this doesn't work in Oracle
dpbradley
+1  A: 

An alternative to InStr() that expresses the SQL a bit more in line with the problem. IMHO.

select * from [table] where [column] like '%'||chr(10)||'%'
David Aldridge
A: 

If you are working with Oracle 10g upwards, you could use

select * from [table] where regexp_like([column], '\n')
Juergen Hartelt