在 SQL 表的文本字符串中查找换行符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13075079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Finding a line break in a text string in a SQL table?
提问by user1542296
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.
我试图在 SQL 表的列中查找换行符和回车符,但我不确定语法。
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?
即使我知道该表应该返回结果,我也没有得到任何结果。我究竟做错了什么?
回答by Chad
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) + '%'
回答by Kaf
SELECT foo FROM Table WHERE foo LIKE '%' + CHAR(13)+CHAR(10) + '%'
回答by Farfarak
Try
尝试
SELECT foo FROM test WHERE foo LIKE '%'+ CHAR(10)+'%'
回答by Marcos Pirmez
Try
尝试
SELECT foo FROM test WHERE foo LIKE CONCAT('%', CHAR(10), '%')

