3

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: 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?

Community
  • 1
  • 1
b.roth
  • 9,421
  • 8
  • 37
  • 50

5 Answers5

3

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

select * from [table] where instr(column, chr(10)) > 0
Vincent Malgrat
  • 66,725
  • 9
  • 119
  • 171
3

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
  • 51,479
  • 8
  • 68
  • 96
1

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

select * from [table] where regexp_like([column], '\n')
Juergen Hartelt
  • 664
  • 4
  • 5
0

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

dpbradley
  • 11,645
  • 31
  • 34
-1

Alternatively:

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

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

tog22
  • 486
  • 1
  • 4
  • 21