Eg: RAW DATA
| ORDER# | SUBORDER# | DISCOUNTS |
|------- |-----------| -------------------------------|
| 1 | 1-123 | '[{ discount:"1",amount:"1"}]' |
| 1 | 1-123 | '[{ discount:"2",amount:"2"}]' |
Want to apply OPENJSON on Discounts and have below OUTPUT:
| ORDER# | SUBORDER# | discount | amount |
|------- |-----------| ---------|------------|
| 1 | 1-123 | 1 | 1 |
| 1 | 1-123 | 2 | 2 |
Msg 137, Level 15, State 2, Line 44
Must declare the scalar variable "@discounts".
I've updated my answer, please add
;
after the insert statement.3.The result is as follows:
