update tb set b=replace(a,'flash','mp3')

解决方案 »

  1.   

    if object_id('ta') is not null drop table ta
    create table ta(a nvarchar(40), b nvarchar(40))
    insert ta select '/flash/3/', ''
    union all select '/flash/1/', ''
    union all select '/flash/2/', ''
    select* from ta
    update ta set b=replace(a, 'flash', 'mp3')
    select* from ta
    drop table ta
      

  2.   

    update tablename(b) set b=replace(a,'flash','mpe') 
      

  3.   

    ---建立测试环境
    create table #a (a varchar(10))insert into #a select '/flash/3/'
    union select '/flash/1/'
    union select '/flash/2/'
    union select '/flash/4/'
    union select '/flash/5/'create table #b (b varchar(10))
    插入满足条件的数据:
    insert into #b select replace(a,'flash','mp3') from #a