例如:原始数据
| ORDER# | SUBORDER# | DISCOUNTS |
|------- |-----------| -------------------------------|
| 1 | 1-123 | '[{ discount:"1",amount:"1"}]' |
| 1 | 1-123 | '[{ discount:"2",amount:"2"}]' |
想要在折扣上应用 OPENJSON 并具有以下输出:
| 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".