I encountered a SQL-Data-Migration (SQL Server) problem and i hope, you can guide me in the right direction.
Assume, we have the table DataTable (names simplified) with the following columns:
DataID | SomeForeignKey | SpecificDataValues | OtherSpecificDataValues
int | int | String | String
-------+----------------+--------------------+------------------------
0 | 1 | ['1','2'] | ['1', '2']
where SpecificDataValues and OtherSpecificDataValues are JSON arrays (like ['1', '2'])
Now i want to migrate this table (with an SQL Migration script at best) to a new table:
DataValuesTable
DataID | SomeForeignKey | SpecificDataValues | OtherSpecificDataValues
-------+----------------+--------------------+------------------------
0 | 1 | 1 | 1
1 | 1 | 2 | 2
So, i basically want to generate a new row in a new table for each value, stored in "SpecificDataValues" and "OtherSpecificDataValues"
I already checked, that there are SQL functions to work with JSON (OPENJSON, JSON_QUERY) but i was not able to produce the desired result using this tools.
I hope, you can show me the right direction.