110,524
社区成员
发帖
与我相关
我的任务
分享
select distinct topic ,
Detail=(select Detail+'' from tb b where a.topic=b.topic for xml path('') )
from tb a
使用查询分析器看的话,过长会被自动截断,用程序获取不会有问题。
INSERT INTO Table_N0
(topic,Detail)
select * from (select distinct topic from Posts0to1000 o) A
outer apply(
select [Details]=STUFF(REPLACE(REPLACE( (select Detail from Posts0to1000 o1 where topic=A.topic for xml auto), '<o1 Detail="', ','), '"/>', ''), 1, 1, '')
)N
Detail是nvarchar(MAX)格式的