首页 > 数据库技术 > 详细

【转】【数据库SQL】SQL查询和替换含有回车,空格,TAB,等

时间:2019-09-16 09:32:55      阅读:103      评论:0      收藏:0      [点我收藏+]

原文链接:https://blog.csdn.net/xiongyongting/article/details/53993519
---如下是查询语句
--查询名称有退格键
select * from t_bd_item_info  where charindex(char(8),item_name) > 0 
go


--查询名称有制表符tab 
select * from t_bd_item_info  where charindex(char(9),item_name) > 0 
go
--查询名称有换行  
select * from t_bd_item_info where charindex(char(10),item_name) > 0 
go
--查询名称有回车  
select * from t_bd_item_info where charindex(char(13),item_name) > 0 
go
--查询名称的空格(前空格、后空格、所有空格)
select * from t_bd_item_info where isnull(charindex(‘ ‘,item_name),0) > 0   
go
--查询名称的单引号 
select * from t_bd_item_info where charindex(char(39),item_name) > 0 
go
--查询名称的双单引号 
select * from t_bd_item_info where charindex(char(34),item_name) > 0 
go

 


--处理名称有退格键
update t_bd_item_info set item_name = replace(item_name,char(8),‘‘) 
where charindex(char(9),item_name) > 0 
go


--处理名称有制表符tab 
update t_bd_item_info set item_name = replace(item_name,char(9),‘‘) 
where charindex(char(9),item_name) > 0 
go
--处理名称有换行  
update t_bd_item_info set item_name = replace(item_name,char(10),‘‘) 
where charindex(char(10),item_name) > 0 
go
--处理名称有回车  
update t_bd_item_info set item_name = replace(item_name,char(13),‘‘) 
where charindex(char(13),item_name) > 0 
go
--处理名称的空格(前空格、后空格、所有空格)
update t_bd_item_info set item_name = replace(rtrim(ltrim(item_name)),‘ ‘,‘‘)  
where isnull(charindex(‘ ‘,item_name),0) > 0   
go
--处理名称的单引号 
update t_bd_item_info set item_name = replace(item_name,char(39),‘‘) 
where charindex(char(39),item_name) > 0 
go
--处理名称的双单引号 
update t_bd_item_info set item_name = replace(item_name,char(34),‘‘) 
where charindex(char(34),item_name) > 0 
go
————————————————
版权声明:本文为CSDN博主「YoTi女程序员的历史」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xiongyongting/article/details/53993519

【转】【数据库SQL】SQL查询和替换含有回车,空格,TAB,等

原文:https://www.cnblogs.com/ningyouyou/p/11525565.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!