用replace函数替换数据库中字符串内容
February 16th, 2009
Mysql替换语句
update ‘表名(比如我案例中的dede_art)’ set 要修改字段名 = replace (要修改字段名,’被替换的特定字符’,'替换成的字符’)
例:
update `dede_art` set title=replace(title,' "IMG border=0 src=Images/hot.gif";','');
MSSQL替换语句:
update 表名 set 字段名=replace(cast(字段名 as varchar(8000)),’abc.com’,’123.com’)
例:
update PE_Article set Content=replace(cast(Content as varchar(8000)),
'http://news.163.com/,'http://www.baizoo.cn/')
'http://news.163.com/,'http://www.baizoo.cn/')
其中PE_Article 为表名 Content为字段名 http://news.163.com/为要替换的内容 http://www.baizoo.cn/为替换后的内容。

这个函数比较好使,前段时间用过。