日期:2014-05-16 浏览次数:20454 次
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
034010100019 034010100019
035010100001;035010100025 035010100001
035010100001;035010100025 035010100025
*/