I have a record in a table Table1 and i want to split that one record into two rows and insert into another table Table2.
Table1
ID Date User value
1 29/05/18 XXX X_ID||X_value||22||xx
2 29/05/18 YYY Y_ID||Y_value||33|yy
and I want table1 values to be inserted into table2 as
Table2
P_ID ID Date User Field Value
1 1 29/05/18 XXX X_ID 22
2 1 29/05/18 XXX X_Value XX
3 2 29/05/18 YYY Y_ID 33
4 3 29/05/18 YYY Y_Value YY
Value from table1 is field in table2 and nothing could be hardcoded as I would be having many records in table table1. EDIT: and what if value in table1 has more values like X_ID||X_VALUE||Y_ID||Y_Value||22||xx||33||yy. How do I make this query dynamic so that irrespective of output it separates record in different rows of table2