日期:2014-05-17 浏览次数:20441 次
with tb(id,attachment_id,attachment_name)
as(
select 1,'1302_1,1302_2,1333_3','一.doc*二.jpg*三.psd*'
),tb1
as(
select t1.id,attachment_id=replace(substring(attachment_id,number+1,charindex(',',attachment_id,number)),',',''),row=row_number()over(order by getdate()) from tb t1,master..spt_values where type='p' and (substring(attachment_id,number,1)=',' or number=0)
),
tb2
as(
select t1.id,attachment_name=replace(substring(attachment_name,number+1,charindex('*',attachment_name,number)),'*',''),row=row_number()over(order by getdate()) from tb t1,master..spt_values where type='p' and (substring(attachment_name,number,1)='*' or number=0)
)
select tb1.id,replace(tb1.attachment_id,'_','/')+'.'+tb2.attachment_name from tb1 join tb2 on tb1.id=tb2.id and tb1.row=tb2.row