日期:2014-05-18 浏览次数:20728 次
--> 测试数据:[tbl]
if object_id('[tbl]') is not null drop table [tbl]
create table [tbl]([id] int,[title] varchar(17))
insert [tbl]
select 1,'2012星光大道:张三' union all
select 2,'2012星光大道:李四' union all
select 3,'2013星光大道:王五'
update tbl
set [title]=REPLACE([title],'2012','2014') where
CHARINDEX('2012星光大道',[title])>0
select * from tbl
/*
id title
1 2014星光大道:张三
2 2014星光大道:李四
3 2013星光大道:王五
*/
------解决方案--------------------
update table set title = replace(title,'2012星光大道','2014星光大道') where title like '2012星光大道%'