数据库字段的拆分
例:表aaa
字段 name sss
dd sd,fdf,999
tt sdf,ew
拆分为
name sss
dd sd
dd fdf
dd 999
tt sdf
tt ew
大虾们帮帮忙
------解决方案--------------------Create Table aaa
(name Varchar(10),
sss Varchar(100))
Insert aaa Select 'dd ', 'sd,fdf,999 '
Union All Select 'tt ', 'sdf,ew '
GO
Select Top 1000 ID = Identity(Int, 1, 1) Into #T From Syscolumns A, Syscolumns B
Select
name,
sss = Substring(A.sss, B.ID, CharIndex( ', ', A.sss + ', ', B.ID) - B.ID)
From aaa A, #T B
Where Substring( ', ' + a.sss, B.id, 1) = ', '
Order By name
Drop Table #T
GO
Drop Table aaa
--Result
/*
name sss
dd sd
dd fdf
dd 999
tt sdf
tt ew
*/