id title
1 2012星光大道:张三
2 2012星光大道:李四
3 2013星光大道:王五
求个sql语句
把title包含 2012星光大道 替换为 2014星光大道
要的结果是
id title
1 2014星光大道:张三
2 2014星光大道:李四
3 2013星光大道:王五
------解决方案--------------------
- SQL code
--> 测试数据:[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 allselect 2,'2012星光大道:李四' union allselect 3,'2013星光大道:王五'update tblset [title]=REPLACE([title],'2012','2014') where CHARINDEX('2012星光大道',[title])>0select * from tbl/*id title1 2014星光大道:张三2 2014星光大道:李四3 2013星光大道:王五*/
------解决方案--------------------
update table set title = replace(title,'2012星光大道','2014星光大道') where title like '2012星光大道%'