JSON support in SQL Server lets you shape result sets as JSON, parse JSON text, and query JSON values straight in T-SQL.
Embed hierarchical data in a single column, return JSON to web apps, and exchange data with NoSQL systems without leaving T-SQL.
Use FOR JSON
at the end of a SELECT to serialize result sets. Choose PATH
for nested objects or AUTO
for quick, flat output.
SELECT id, name, price FROM Products FOR JSON PATH;
Call OPENJSON()
to split JSON text into rows, optionally applying a schema for typed columns.
SELECT * FROM OPENJSON(@jsonCart) WITH (product_id INT, quantity INT);
JSON_VALUE()
extracts a scalar, while JSON_QUERY()
returns an object or array. Both accept a JSON path string.
SELECT JSON_VALUE(order_json,'$.total_amount') AS total FROM Orders;
Create a computed column using JSON_VALUE()
and add a normal B-tree index, or use a full-text index for entire documents.
Validate JSON with ISJSON()
before processing; store only necessary fragments to avoid bloated rows; keep paths stable for maintainability.
No. JSON is stored as NVARCHAR. Functions parse on the fly.
Yes. Use JSON_MODIFY(column,'$.path',newValue)
inside an UPDATE statement.