How can I check if an SQL result contains a newline character?

NibblyPig picture NibblyPig · Oct 6, 2010 · Viewed 72.1k times · Source

I have a varchar column that contains the string lol\ncats, however, in SQL Management Studio it shows up as lol cats.

How can I check if the \n is there or not?

Answer

LukeH picture LukeH · Oct 6, 2010
SELECT *
FROM your_table
WHERE your_column LIKE '%' + CHAR(10) + '%'

Or...

SELECT *
FROM your_table
WHERE CHARINDEX(CHAR(10), your_column) > 0