sql语句实现将一列数据转化为字符串的代码。
复制代码 代码示例:
SELECT DISTINCT
u1.[ItemCode] ,
REPLACE(( SELECT u2.[DetailDescription] + ',' AS 'data()'
FROM [YinTaiContent].[dbo].ItemProfileDetails u2
WHERE u2.[ItemCode] = u1.[ItemCode]
FOR
XML PATH('')
) + '$', ',$', '') AS Roles
FROM [dbo].ItemProfileDetails u1
WHERE u1.ItemCode = '09-001-0039'