a little just a continuation of my last topic. I have table:
id | values |
---|---|
1 | 2;1|3;5|4;8|9;8|10;12 |
2 | 0;2|1;3|5;6 |
3 | 3;5|1;5|4;7|6;9 |
Column values is varchar and i need modify, that I get each number separately
I don't care if in new columns or as separate values in the same column.
id | values |
---|---|
1 | 2 |
1 | 1 |
1 | 3 |
1 | 5 |
1 | 4 |
1 | 8 |
1 | 9 |
1 | 8 |
1 | 10 |
1 | 12 |
or
id | values | x1 | y1 | x2 | y2 | x3 | y3 | x4 | y4 | x5 | y5 |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2;1|3;5|4;8|9;8|10;12 | 2 | 1 | 3 | 5 | 4 | 8 | 9 | 8 | 10 | 12 |
Both solutions would be great for me. i tried to achieve this at sql level and potentially using ssis:
SELECT values,
SUBSTRING(values, 1, CHARINDEX(';', values)-1) AS x1,
SUBSTRING(values,1,CHARINDEX(';', values)+1) AS y1
/*CONVERT(float,STUFF(values,1,CHARINDEX(';',values),'')) AS y1
CONVERT(float,LEFT(UserGuid,CHARINDEX(';',UserGuid)-1)) AS x1
,CONVERT(float,LEFT(UserGuid,CHARINDEX(';',UserGuid)-1)) AS x2,
,SUBSTRING(UserGuid, CHARINDEX(';', UserGuid) + 1, 1000) AS y2 */
FROM table
But I was told that this would be difficult to achieve at the sql level.
This adjustment may be necessary using some side scripting, any idea and suggestion will be great for me. Thank you