OPENJSON lets you shred JSON text into relational rows and columns directly inside SQL Server.
OPENJSON converts JSON arrays or objects into a tabular result set you can join, filter, and aggregate with regular T-SQL. It eliminates CLR code and speeds up ETL pipelines.
OPENJSON (json_expression [, path ]) WITH (schema_definition) returns one row per JSON element. The WITH clause casts JSON values to SQL data types and assigns column names.
SELECT * FROM Orders CROSS APPLY OPENJSON(orders.json_payload) WITH (...column list…) as j; The CROSS APPLY feeds each row’s JSON into OPENJSON, expanding it on the fly.
Yes. Specify a path argument or use dot-notation in the WITH clause. Example: product.price AS price money '$.details.price'.
The OrderItems table can hold an extra json_details nvarchar(max) column for tax and discount data. Use OPENJSON to materialize those values only when needed, keeping storage flexible.
1) Keep JSON columns nvarchar(max). 2) Create computed persisted columns for frequently queried keys. 3) Index computed columns, not raw JSON, for speed.
Use the strict modifier (OPENJSON WITH … STRICT) to fail fast on bad JSON. Avoid SELECT *, project only required fields. Combine with APPLY instead of a subquery for readability.
OPENJSON requires SQL Server 2016 (13.x) or later and is included in all editions except SQL Server Compact.
Yes. Malformed JSON throws error 13609 unless you add the LAX modifier. Use STRICT to enforce full compliance.
Yes, use JSON_MODIFY to replace or append values, then persist the string back to the column.