日期:2014-05-17  浏览次数:20475 次

请教如何更新,非常感谢!
SQL code

create table #(bm varchar(20) not null)

insert #
select  '12345|g'
union all
select '123456|ml'
union all
select '2345|支'
union all
select '5678910|tttt'

----请问如何替换"|"之前的数据,非常感谢!



------解决方案--------------------
SQL code
SELECT 'a'+RIGHT(bm,LEN(bm)-CHARINDEX('|',bm)+1) FROM #

------解决方案--------------------
SQL code
select REPLACE ( #a.bm , substring(#a.bm,1,charindex('|',#a.bm) - 1) , #b.mc ) from #a ,#b where #a.id=#b.id