--EDIT: original table sample, requested in comments
job_id | change_id | change |
---|---|---|
1 | 1 | 5□6□ |
1 | 2 | 7□8□ |
1 | 3 | 9□10□ |
2 | 4 | 1□3□ |
This is a C# reflection of an object to serialise the data in the Change field.
The desired result is the following:
Job ID | Change ID | Change from | Change to |
---|---|---|---|
1 | 1 | 5 | 6 |
1 | 2 | 7 | 8 |
1 | 3 | 9 | 10 |
2 | 4 | 1 | 3 |
I managed to identify the character as CHAR(1), in order to be able to split it using the following query (which lead to the unpivoted table, which might or might not be useful- apparently not as per comments below, since the order is uncertain):
SELECT job_id, change_id, VALUE change
FROM change_table
CROSS APPLY STRING_SPLIT(change,CHAR(1))
Job ID | Change ID | Changes |
---|---|---|
1 | 1 | 5 |
1 | 1 | 6 |
1 | 1 | |
1 | 2 | 7 |
1 | 2 | 8 |
1 | 2 | |
1 | 3 | 9 |
1 | 3 | 10 |
1 | 3 | |
2 | 4 | 1 |
2 | 4 | 3 |
2 | 4 |