如何在 SQL Server 2019 中实现这一点?我有一个订单表,其中有一lineaggregate
列包含一个 json 字符串,其中包含已发货的行项目详细信息。我需要将每个变体 ID 和数量提取到单独的行中(每个变体 ID 1 行)。
下面是一个实际的 json 字符串示例:
[
{
"id": 4379711799354,
"variant_id": 31291380727866,
"title": "*NEW* Kayslin Sneaker in Blush",
"quantity": 1,
"sku": "79000212",
"variant_title": "3Y",
"vendor": "TESTVENDOR",
"fulfillment_service": "manual",
"product_id": 4371426607162,
"requires_shipping": true,
"taxable": true,
"gift_card": false,
"name": "*NEW* Kayslin Sneaker in Blush - 3Y",
"variant_inventory_management": "shopify",
"properties": [
{
"name": "Item Ships Separately",
"value": "✓"
}
],
"product_exists": true,
"fulfillable_quantity": 0,
"grams": 490,
"price": "68.00",
"total_discount": "0.00",
"fulfillment_status": "fulfilled",
"pre_tax_price": "68.00",
"price_set": {
"shop_money": {
"amount": "68.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "68.00",
"currency_code": "USD"
}
},
"pre_tax_price_set": {
"shop_money": {
"amount": "68.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "68.00",
"currency_code": "USD"
}
},
"total_discount_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
},
"discount_allocations": [],
"admin_graphql_api_id": "gid:\/\/shopify\/LineItem\/4379711799354",
"tax_lines": [
{
"title": "CT STATE TAX",
"price": "0.00",
"rate": 0.0,
"price_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
}
}
],
"origin_location": {
"id": 624876322874,
"country_code": "US",
"province_code": "TX",
"name": "Joyfolie",
"address1": "1809 W Frankford Rd #160 ",
"address2": "",
"city": "Carrollton",
"zip": "75007"
}
},
{
"id": 4379711832122,
"variant_id": 31031946838074,
"title": "*NEW* Mama Bird Necklace Set in Gold",
"quantity": 1,
"sku": "83000109",
"variant_title": "",
"vendor": "TESTVENDOR",
"fulfillment_service": "manual",
"product_id": 4320751878202,
"requires_shipping": true,
"taxable": true,
"gift_card": false,
"name": "*NEW* Mama Bird Necklace Set in Gold",
"variant_inventory_management": "shopify",
"properties": [],
"product_exists": true,
"fulfillable_quantity": 0,
"grams": 113,
"price": "29.50",
"total_discount": "0.00",
"fulfillment_status": "fulfilled",
"pre_tax_price": "29.50",
"price_set": {
"shop_money": {
"amount": "29.50",
"currency_code": "USD"
},
"presentment_money": {
"amount": "29.50",
"currency_code": "USD"
}
},
"pre_tax_price_set": {
"shop_money": {
"amount": "29.50",
"currency_code": "USD"
},
"presentment_money": {
"amount": "29.50",
"currency_code": "USD"
}
},
"total_discount_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
},
"discount_allocations": [],
"admin_graphql_api_id": "gid:\/\/shopify\/LineItem\/4379711832122",
"tax_lines": [
{
"title": "CT STATE TAX",
"price": "0.00",
"rate": 0.0,
"price_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount":