Ask Your Question
0

LIKE expression to find newlines

asked 2018-11-06 12:45:35 +0100

stanton gravatar image

updated 2018-11-06 12:52:27 +0100

I would like to find all records where a certain field ends with a newline. Here's what I've tried so far:

SELECT * FROM foo WHERE bar LIKE '%' + CHAR(10);
SELECT * FROM foo WHERE bar LIKE U&'%\000A';
SELECT * FROM foo WHERE bar LIKE '%\000A';
SELECT * FROM foo WHERE bar LIKE '%\0A';

The first two are rejected as syntax errors. The second two run but return zero records (despite there being records with trailing newlines), which leads me to the conclusion that what I intended to be a newline is not understood as such.

What is the correct way to specify a newline in a LIKE expression?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-11-06 13:17:26 +0100

stanton gravatar image

This worked:

SELECT * FROM foo WHERE bar LIKE CONCAT('%', CHAR(10));
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-06 12:45:35 +0100

Seen: 19 times

Last updated: Nov 06 '18