【转】【数据库SQL】SQL查询和替换含有回车,空格,TAB,等
原文链接: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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构