本帖最后由 xiaxue77701 于 2014-02-26 15:35:15 编辑

解决方案 »

  1.   

    create table tb(prd_no_chg_y varchar(30),prd_no_chg varchar(100))insert into tb
    select '034010100019'   ,           '034010100019' union all
    select '035010100001;035010100025',   '035010100001;035010100025'
    go
    select prd_no_chg_y,
           SUBSTRING(t.prd_no_chg_y, number ,CHARINDEX(';',t.prd_no_chg_y+';',number)-number) prd_no_chg
    from tb t,master..spt_values s
    where s.number >=1
    and s.type = 'P'
    and SUBSTRING(';'+t.prd_no_chg_y,s.number,1) = ';'
    /*
    prd_no_chg_y prd_no_chg_y
    034010100019 034010100019
    035010100001;035010100025 035010100001
    035010100001;035010100025 035010100025
    */
      

  2.   

    试试这个:
    create table tb(prd_no_chg_y varchar(30),prd_no_chg varchar(100))insert into tb
    select '034010100019'   ,           '034010100019' union all
    select '035010100001;035010100025',   '035010100001;035010100025'
    goselect prd_no_chg_y,
           SUBSTRING(t.prd_no_chg_y, number ,CHARINDEX(';',t.prd_no_chg_y+';',number)-number) prd_no_chg
    from tb t,master..spt_values s
    where s.number >=1
    and s.type = 'P'
    and SUBSTRING(';'+t.prd_no_chg_y,s.number,1) = ';'
    /*
    prd_no_chg_y prd_no_chg
    034010100019 034010100019
    035010100001;035010100025 035010100001
    035010100001;035010100025 035010100025
    */