Soldato
I have a table as follows:
What I need is a mechnism to iterate through the delimited values in ColumnB and generate a new table as follows.
Kinda gets there but balks where ColumnB is empty or does not contain the delimiter ";" (or at least I thinks that's why it balks.).
Appreciate any pointers, TIA Paul!
Code:
ColumnA ColumnB
Fruit Apple;Pear;Banana
Code:
ColumnA ColumnB
Fruit Apple
Fruit Pear
Fruit Banana
Code:
SELECT a.ColumnA,
split.a.value('.', 'VARCHAR(100)') As ColumnB
from
(select ColumnA,
cast('<M>' + replace(ColumnB, ';', '</M><M>') + '</M>' AS XML) As ColumnB
from Table1
) as a cross apply ColumnB.nodes ('/M') as split(a)
Kinda gets there but balks where ColumnB is empty or does not contain the delimiter ";" (or at least I thinks that's why it balks.).
Appreciate any pointers, TIA Paul!
Last edited: