SqlServer将列多个值拆分到行
原始数据:
目标数据:
方法:
SELECT a.Province_Code, a.Country_Code, c.value('.', 'nvarchar(64)') AS Province_Name FROM HR_Province a CROSS APPLY (SELECT CAST('<row>' + REPLACE(a.Keywords, ',', '</row><row>') + '</row>' AS XML) AS XMLCode) b CROSS APPLY XMLCode.nodes('*') (c)