sql 字符串替换
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://edu.cnzz.cc/') 其中PE_Article 为表名 Content为字段名 http://news.163.com/为要替换的内容 http://edu.cnzz.cc/为替换后的内容。 操作方法很简单,用查询分析器。
update TE_Scenery set S_Text= replace(cast(S_Text as nvarchar(max)), 'src="/uploads/', 'src="http://www.lyydw.com/uploads/') where s_name='白云源'
select * from dbo.TE_Scenery where s_name='绍兴乔波冰雪世界' select * from dbo.TE_Scenery where S_Traffic like '%src="/uploads/%' and s_name='商量岗旅游度假区' select * from dbo.TE_Scenery where S_Traffic like '%src="/uploads/%' and s_name='横店影视城'
update TE_Scenery set S_Traffic= replace(cast(S_Traffic as nvarchar(max)), 'src="/uploads/', 'src="http://www.lyydw.com/uploads/') where s_name='绍兴乔波冰雪世界'