html select制表符变形,SQL查询和替换含有回车,空格,TAB,等

该博客主要展示了如何使用SQL查询语句检测并处理数据库表中item_name字段存在的特殊字符,包括退格键、制表符、换行、回车、空格、单引号和双引号。通过`charindex()`函数定位特殊字符,然后用`replace()`函数进行替换,确保数据的规范性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

--如下是查询语句

--查询名称有退格键

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值