一佳一

记录像1+1一样简洁的代码

导航

SQL 逗号分隔将一行拆成多行

Posted on 2018-07-12 14:38  一佳一  阅读(590)  评论(0编辑  收藏  举报
select PID, SUBSTRING(a.KOrderID,number,CHARINDEX(',',a.KOrderID+',',number)-number) as KOrderID from  TB a,master..spt_values 

where
number >=1 and number<=len(a.KOrderID) and type='p' and substring(','+a.KOrderID,number,1)=',')