Shred JSON Data into Rows and Columns with T-SQL
Use OPENJSON with a WITH schema and CROSS APPLY to convert JSON objects and nested arrays into relational rows and columns; validate with ISJSON , set database compatibility level ≥130, and add computed/indexed columns for performance. Quick recipe (what to run) Validate JSON : use ISJSON() before shredding. Parse root object : CROSS APPLY OPENJSON(... ) WITH (...) to map properties to typed columns. Shred arrays : CROSS APPLY OPENJSON(rootJson, '$.ArrayName') to return rows, then OPENJSON(... ) WITH (...) to extract fields from each array element. Example: order JSON → rows and columns sql DECLARE @j NVARCHAR(MAX) = N' { "OrderId":"0001", "Customer":{"Name":"Amanda","Email":"a@example.com"}, "Items":[ {"Name":"Heated Blanket","Qty":1,"Price":49.99}, {"Name":"Glove Warmers","Qty":2,"Price":9.99} ...