Good day!
Maybe you can help me, or tell me if what I want to do is impossible or totally wrong...
I was trying to create a sqlfiddle but it seems the page is down at the moment.
(SQL Server 2008) I have a table, lets say that it has 3 columns, but the person who designed it didn't normalize, so one column holds multiple values, it's something like this:
IdCol Col1 Col2 Col3
1 a1 b1 a, b, c
2 a2 b2 d, e, f
As you can see, Col3 holds multiple values separated by ","
what I want to achieve, is to create a view (can't modify the table because they won't allow me to modify the application) that is something similar to this:
NewIdCol IdCol Col1 Col2 Col3
1 1 a1 b1 a
2 1 a1 b1 b
3 1 a1 b1 c
4 2 a2 b2 d
5 2 a2 b2 e
6 2 a2 b2 f
So the final result has Col3 values split into a different row and every other column's value copied. (the actual table has about 20 columns, and 2 of those columns hold multiple values, so I would need to do it for both columns)
At first I thought it would be easy... but then I hit a block on how to split that string... first I thought about using a split function, but then I didn't know how to join it back with the rest of the columns...
Thanks in advance.