--N要连继,
select top 8000 identity(int,1,1) as N into numtab from
(select top 100 id=1 from sysobjects) as a,
(select top 100 id=1 from sysobjects) as b,
(select top 100 id=1 from sysobjects) as c---------------------------------------------------------------------
declare @a table (id int,string varchar(8000))
insert @a select 1 ,'a,b,c,sd,dfsdfg'
union select 2, 'a,n,sdf,we,t'
union select 3, 's,df,df'select a.*,b.*,id,substring(','+string+',',N+1,charindex(',',','+string+',',N+1)-(N+1))
from @a a,numtab b
where substring(','+string+',',N,8000) like ',_%'
order by id,N
select top 8000 identity(int,1,1) as N into numtab from
(select top 100 id=1 from sysobjects) as a,
(select top 100 id=1 from sysobjects) as b,
(select top 100 id=1 from sysobjects) as c---------------------------------------------------------------------
declare @a table (id int,string varchar(8000))
insert @a select 1 ,'a,b,c,sd,dfsdfg'
union select 2, 'a,n,sdf,we,t'
union select 3, 's,df,df'select a.*,b.*,id,substring(','+string+',',N+1,charindex(',',','+string+',',N+1)-(N+1))
from @a a,numtab b
where substring(','+string+',',N,8000) like ',_%'
order by id,N
select f1,f2,f3=substring(c.f3,(a.n * 10 + b.n )*3 + 1,2)
from (select n = 1 union select 2 union select 3 union select 4
union select 5 union select 6 union select 7
union select 8 union select 9 union select 0) as a,
(select n = 1 union select 2 union select 3 union select 4
union select 5 union select 6 union select 7
union select 8 union select 9 union select 0) as b,
你的表名 c
where len(c.f3) > (a.n * 10 + b.n )*3两个一起学习,吃饭后再结:)
看看:
http://expert.csdn.net/Expert/topic/1401/1401590.xml?temp=1.389712E-02