查询含有换行符的记录?该如何解决
查询含有换行符的记录?
要替换所有记录中含有某字段的换行符,可以用
update 表名 set 某字段=replace(某字段,char(13),'')
但是如果只是想找到那些有换行符的记录呢?例如我们要抓录入规范化,要根据记录进行考核
------解决方案--------------------
要替换所有记录中含有某字段的换行符,可以用
update 表名 set 某字段=replace(某字段,char(13),'')
但是如果只是想找到那些有换行符的记录呢?例如我们要抓录入规范化,要根据记录进行考核
------解决方案--------------------
- SQL code
/*制表符 char(9) 换行符 char(10) 回车符 char(13) */ update tb set col=REPLACE(col,char(10),'k') select * from tb where COL like '%k%' 先用特殊字符替换完毕,然后再查 最后在更新成 update tb set col=REPLACE(col,char(10),'')
------解决方案--------------------
- SQL code
select col from tbl where charindex(CHAR(10),col)>0 select charindex(CHAR(10),'tadg'+CHAR(10)+'etjdfd') /* 5 */