SQL查詢和替換含有回車,空格,TAB,等


---如下是查詢語句
--查詢名稱有退格鍵
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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM