I have a function to split CSVs up. I have data like this:
identifier values
123 abc,def,ghi
124 jre,ds,qwert
And I want the output to be:
123 abc
123 def
123 ghi
124 jre
124 ds
124 qwert
How do I go about doing this?
Thanks, Harry
This is what I currently have;
SELECT CustomRecordsetId, LTRIM(Value) AS my_values
FROM
(
SELECT *,
CAST('<X>'+replace(Value,',','</X><X>')+'</X>' as XML) as my_Xml
FROM dbo.CustomFieldValue where CustomFieldId=177
) T1
CROSS APPLY
(
SELECT my_Data.D.value('.','varchar(50)') as my_Splits
FROM T1.my_Xml.nodes('X') as my_Data(D)
) T2
Although this is returning;
id | values
596 | 151, 313
596 | 151, 313
603 | 165
604 | 187
605 | 174
606 | 181, 182
606 | 181, 182