Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Split multiple columns into rows using XML

$
0
0

Hi Forum,

I am trying to split 2 columns that each contain values separated by semicolon into single rows. The relation between the values of the two columns is that the order in the cells corresponds to each other.

The data looks like this:

pk    Manufacturer                partnumber
1     Man1; Man2;Man3      PN1;PN2;PN3
2     Man4; Man2;Man5      PN4;PN5;PN6

The result should be:

pk    Manufacturer     partnumber
1       Man1                   PN1
1       Man2                   PN2
1       Man3                   PN3
2       Man4                   PN4
2       Man2                   PN5
2       Man5                   PN6

I am not sure how to format the XML to get a useful Basis for XML.value or XML.query

Any ideas?

TIA
Alex



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>