Finding a line break in a text string in a SQL tab

2020-06-06 19:09发布

I was trying to find line breaks and carriage returns in a column in a SQL table and I am not sure about the syntax.

I tried:

SELECT foo FROM test
WHERE foo LIKE CHAR(10)

I didn't get any results even though I know that the table should return results. What am I doing wrong?

4条回答
看我几分像从前
2楼-- · 2020-06-06 19:25

Try

  SELECT foo FROM test WHERE foo LIKE '%'+ CHAR(10)+'%'
查看更多
贼婆χ
3楼-- · 2020-06-06 19:30
SELECT foo FROM Table WHERE foo LIKE '%' + CHAR(13)+CHAR(10) + '%'
查看更多
Deceive 欺骗
4楼-- · 2020-06-06 19:45
SELECT foo FROM test WHERE foo LIKE '%' + CHAR(10) + '%'

Edit: to find all various types of line endings you should probably just check both:

SELECT foo FROM test WHERE foo LIKE '%' + CHAR(10) + '%'
                        OR foo LIKE '%' + CHAR(13) + '%'
查看更多
smile是对你的礼貌
5楼-- · 2020-06-06 19:46

Try

SELECT foo FROM test WHERE foo LIKE CONCAT('%', CHAR(10), '%')
查看更多
登录 后发表回答