首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

怎么查询字段中的%,怎么替换%全角的百分号

2012-01-07 
如何查询字段中的%,如何替换%全角的百分号如何查询字段中的%,如何替换%全角的百分号[解决办法]update tb s

如何查询字段中的%,如何替换%全角的百分号
如何查询字段中的%,如何替换%全角的百分号

[解决办法]
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(列名, '% ', '% ')

热点排行