create table tb(id int,mytype varchar(400))
insert into tb
select 1, 'a,b,c,d' union all
select 2, 'c,f,a' union all
select 3, 'g'
declare @id int,@mytype varchar(10)
declare @tb table (id int,mytype varchar(10))
declare cur cursor for
select id,mytype from tb
open cur
fetch next from cur into @id,@mytype
while @@fetch_status=0
begin
set @mytype=@mytype+ ','
while charindex( ',',@mytype)> 0
begin
insert into @tb values(@id,left(@mytype,charindex( ',',@mytype)-1) )
set @mytype=right(@mytype,len(@mytype)-charindex( ',',@mytype))
end
fetch next from cur into @id,@mytype
end
select * from @tb
go
2004

被折叠的 条评论
为什么被折叠?



