日期:2014-05-17 浏览次数:20596 次
declare @table1 table (列A char(1),列B nvarchar(20))
insert into @table1
select 'a','123 替换' union all
select 'b','234 替换' union all
select 'c','434 替换' union all
select 'd','2334 替换'
--需求:如何将B列中所有行中最后的 “替换”改为“替换后字段”呢。谢谢!
update @table1 set 列B=replace(列B,'替换','替换后字段')
select * from @table1
/*
结果:
列A 列B
---------------------------------
a 123 替换后字段
b 234 替换后字段
c 434 替换后字段
d 2334 替换后字段
消息:
(4 行受影响)
(4 行受影响)
(4 行受影响)
*/