SQL Flow Field Guide

JSON_QUERY

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

JSON extract, test, modify or construct

What changes

Input
JSON text or values
Output or change
scalar, fragment, or constructed JSON
Return type
Returns a JSON fragment of type nvarchar(max). The collation of the returned value is the same as the collation of the input expression. If the value isn't an object or an array: In lax mode, JSON_QUE

Syntax at a glance

JSON_QUERY ( expression [ , path ] [ WITH ARRAY WRAPPER ] )

Work example

Read an object or array fragment from a JSON document.

Use JSON_VALUE for a scalar and JSON_QUERY for a nested object or array.

Check your work In lax mode, a scalar at the selected path returns null rather than an object fragment.

Practice SQL

Open in SQL Flow
SELECT JSON_QUERY(N'{"items":[1,2]}', '$.items') AS items;

Open Microsoft Learn for full syntax, permissions, and details for your version.