帮写一条更新语句门牌1号
门牌12号
门牌111号
门牌123号
门牌1123号
门牌2131号
门牌2131号
门牌1231号
测试1号
测试2号
测试3号
写一条更新语句 
使得这列更新后结果
门牌1号
门牌1号
门牌1号
门牌1号
门牌1号
门牌1号
门牌1号
门牌1号
测试1号
测试1号
测试1号

解决方案 »

  1.   

    update tb
    set col=left(col,2)+'1号'
      

  2.   


    update tb
    set coul = substring(col,1,patindex('%[0-9]%',col)-1)+'1号'
      

  3.   

    UPDATE TB SET COL=
    CASE 
    WHEN COL LIKE '门牌%' THEN '门牌1号' 
    WHEN COL LIKE '测试%' THEN '测试1号' END
      

  4.   

    update a set
      col = (select top 1 col from tab where left(col,2)=left(a.col,2) order by col)
    from tab a
      

  5.   

    create table tb1(name varchar(20))
    insert into tb1
    select '门牌1号' union all
    select '门牌12号' union all
    select '门牌111号' union all
    select '门牌123号' union all
    select '门牌1123号' union all
    select '门牌2131号' union all
    select '门牌2131号' union all
    select '门牌1231号' union all
    select '测试1号' union all
    select '测试2号' union all
    select '测试3号'update tb1
    set name='门牌1号'
    where name like '%门牌%'update tb1
    set name='测试1号'
    where name like '%测试%'