Skip to main content

Hi.

I aheba question for you all:

 

I have a table for example link this

filed_name:Format

Product_id: Integer

Delivery_metod: varchar(50)

Inventory_id: Integer

Inventory_Entries: JSON

 

Inventory_entries can contain one or several entries in JSON format like this:

[{"SKU":"A","Price":"100"},{"SKU":"B","Price":""00"}]

 

Instead off one line with the json entries nested into one single field i would like to Normalize the tabel into several lines, one for each SKU.

 

Any ideas?

 

 

 

If your field Inventory_Entries has a maximum number of entries per Inventory_id, I would suggest:

1. CROSS APPLY or UNPIVOT the Inventory_Entries field into a temp table or a custom table

2. LEFT JOIN that new temp /custom table to your original table and store the output of that join in another custom table

Since I can't tell what the PK is of your table, I can only suggest that it's best to unpivot or cross apply round your PK and perform your join on that. I assumed here that it's Inventory_id.

Kind Regards,

Wim