Search code examples
sqlsql-server

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


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?


Solution

  • SELECT *
    FROM your_table
    WHERE your_column LIKE '%' + CHAR(10) + '%'
    

    Or...

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