日期:2014-05-17 浏览次数:20429 次
declare @sql nvarchar(100)
;with tb(txt)
as(
select 'saasdsdf*addfb*sdc'
)
select @sql=isnull(@sql,'')+','''+col+'''' from(select col=left(stuff(txt,1,number-1,''),charindex('*',stuff(txt,1,number,'')+'*'))
from tb,master..spt_values where type='p' and number between 1 and len('*'+txt) and substring('*'+txt,number,1)='*'
)t
set @sql='select '+stuff(@sql,1,1,'')
exec(@sql)