如何查询字段中的%,如何替换%全角的百分号
如何查询字段中的%,如何替换%全角的百分号
[解决办法]
update tb set col=replace(col, '% ', '% ')
[解决办法]
--如何替换%全角的百分号
Create Table TEST
(IDInt,
NameVarchar(100))
Insert TEST Select 1, '2%3 '
Union All Select 2, '%23 '
Union All Select 2, '23 '
GO
Update TEST Set Name = Replace(Name, '% ', '% ')
Select * From TEST
GO
Drop Table TEST
--Result
/*
IDName
12%3
2%23
223
*/
[解决办法]
select * from table where charindex( '% ',列名)> 0
update table set 列名=replace(列名, '% ', '% ')
[解决办法]
在保留字如%上加上[]进行运算.
[解决办法]
update table set 列名=replace(列名, '% ', '% ')
Create Table TEST2
(IDInt,
NameVarchar(100))
Insert TEST2 Select 1, '2%3 '
Union All Select 2, '%23 '
Union All Select 2, '23 '
GO
Select * From TEST2 Where Name Like '% '+QUOTENAME ( '% ')+ '% '
GO
Drop Table TEST2
[解决办法]
update table set 列名=replace(列名, '% ', '% ')