I would like to split a string with a variable number of values into different columns.
I know that It exist a solution 'PIVOT' but I'm not sure this will works when the number of value is not the same.
Here is an example:
+-----+-----------+
| Key | Value |
+-----+-----------+
| 1 | A,B,C |
| 2 | A,B,C,D |
| 3 | A,B,C,D,E |
+-----+-----------+
Result:
+-----+------+------+------+------+------+
| Key | Col1 | Col2 | Col3 | Col4 | Col5 |
+-----+------+------+------+------+------+
| 1 | A | B | C | | |
| 2 | A | B | C | D | |
| 3 | A | B | C | D | E |
+-----+------+------+------+------+------+
I know that there is at least 1 value and maximum 5 values in the string, so I have to generate 5 columns and filing it accordingly.
