Skip to content

Commit 9e40bb7

Browse files
Merge pull request #36568 from rwestMSFT/rw-0205-fix-550234
RETURNING was only added in SQL Server 2025 (UUF 550234)
2 parents cdb0e03 + 5635543 commit 9e40bb7

1 file changed

Lines changed: 36 additions & 15 deletions

File tree

docs/t-sql/functions/json-value-transact-sql.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: JSON_VALUE extracts a scalar value from a JSON string.
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
66
ms.reviewer: jovanpop, umajay, randolphwest
7-
ms.date: 10/27/2025
7+
ms.date: 02/05/2026
88
ms.service: sql
99
ms.subservice: t-sql
1010
ms.topic: reference
@@ -25,56 +25,77 @@ monikerRange: "=azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 |
2525

2626
[!INCLUDE [sqlserver2016-asdb-asdbmi-asa-fabricse-fabricdw-fabricsqldb](../../includes/applies-to-version/sqlserver2016-asdb-asdbmi-asa-fabricse-fabricdw-fabricsqldb.md)]
2727

28-
The `JSON_VALUE` syntax extracts a scalar value from a JSON string.
28+
Use the `JSON_VALUE` syntax to extract a scalar value from a JSON string.
2929

3030
To extract an object or an array from a JSON string instead of a scalar value, see [JSON_QUERY](json-query-transact-sql.md). For info about the differences between `JSON_VALUE` and `JSON_QUERY`, see [Compare JSON_VALUE and JSON_QUERY](../../relational-databases/json/validate-query-and-change-json-data-with-built-in-functions-sql-server.md#JSONCompare).
3131

3232
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
3333

3434
## Syntax
3535

36+
::: moniker range="<=sql-server-linux-ver16 || <=sql-server-ver16"
37+
38+
Syntax for [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and earlier versions.
39+
40+
```syntaxsql
41+
JSON_VALUE ( expression , path )
42+
```
43+
44+
::: moniker-end
45+
46+
::: moniker range=">=sql-server-linux-ver17 || >=sql-server-ver17"
47+
48+
Syntax for [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] and later versions.
49+
3650
```syntaxsql
3751
JSON_VALUE ( expression , path [ RETURNING data_type ] )
3852
```
3953

54+
> [!NOTE]
55+
> In [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and earlier versions, [RETURNING isn't included](?view=sql-server-ver16&preserve-view=true#syntax).
56+
57+
::: moniker-end
58+
4059
## Arguments
4160

4261
#### *expression*
4362

44-
An expression. Typically the name of a variable or a column that contains JSON text.
63+
An expression that's typically the name of a variable or a column containing JSON text.
4564

4665
If `JSON_VALUE` finds JSON that isn't valid in *expression* before it finds the value identified by *path*, the function returns an error. If `JSON_VALUE` doesn't find the value identified by *path*, it scans the entire text and returns an error if it finds JSON that isn't valid anywhere in *expression*.
4766

4867
#### *path*
4968

50-
A JSON path that specifies the property to extract. For more info, see [JSON Path Expressions in the SQL Database Engine](../../relational-databases/json/json-path-expressions-sql-server.md).
69+
`A JSON` path that specifies the property to extract. For more info, see [JSON path expressions in the SQL Database Engine](../../relational-databases/json/json-path-expressions-sql-server.md).
5170

5271
In [!INCLUDE [sssql17-md](../../includes/sssql17-md.md)] and in [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)], you can provide a variable as the value of *path*.
5372

5473
If the format of *path* isn't valid, `JSON_VALUE` returns an error.
5574

5675
#### *data_type*
5776

58-
Return the value specified in the SQL type. Only supported if the input is a JSON type. The supported SQL types are: **tinyint**, **smallint**, **int**, **bigint**, **decimal**, **numeric**, **float**, **real**, **char**, **varchar**, **varchar(max)**, **nchar**, **nvarchar**, **nvarchar(max)**, **date**, **time**, **datetime2**, and **datetimeoffset**.
77+
The data type that you want to use for the return value. This type is only supported if the input is a JSON type. The supported data types are: **tinyint**, **smallint**, **int**, **bigint**, **decimal**, **numeric**, **float**, **real**, **char**, **varchar**, **varchar(max)**, **nchar**, **nvarchar**, **nvarchar(max)**, **date**, **time**, **datetime2**, and **datetimeoffset**.
5978

6079
## Return value
6180

62-
If `RETURNING` isn't included:
81+
**Applies to**: [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] and later versions.
82+
83+
If you don't include `RETURNING`:
6384

64-
- Returns a single text value of type nvarchar(4000). The collation of the returned value is the same as the collation of the input expression.
85+
- Returns a single text value of type **nvarchar(4000)**. The collation of the returned value matches the collation of the input expression.
6586

66-
- If the value is greater than 4000 characters:
87+
- If the value is greater than 4,000 characters:
6788

6889
- In lax mode, `JSON_VALUE` returns `NULL`.
6990
- In strict mode, `JSON_VALUE` returns an error.
7091

71-
If you have to return scalar values greater than 4000 characters, use `OPENJSON` instead of `JSON_VALUE`. For more info, see [OPENJSON](openjson-transact-sql.md).
92+
If you need to return scalar values greater than 4,000 characters, use `OPENJSON` instead of `JSON_VALUE`. For more information, see [OPENJSON](openjson-transact-sql.md).
7293

73-
If `RETURNING` is included:
94+
If you include `RETURNING`:
7495

75-
Returns the value specified in the SQL type. The supported SQL types are: **tinyint**, **smallint**, **int**, **bigint**, **decimal**, **numeric**, **float**, **real**, **char**, **varchar**, **varchar(max)**, **nchar**, **nvarchar**, **nvarchar(max)**, **date**, **time**, **datetime2**, and **datetimeoffset**.
96+
Returns the value specified in *data_type*. The supported data types are: **tinyint**, **smallint**, **int**, **bigint**, **decimal**, **numeric**, **float**, **real**, **char**, **varchar**, **varchar(max)**, **nchar**, **nvarchar**, **nvarchar(max)**, **date**, **time**, **datetime2**, and **datetimeoffset**.
7697

77-
JSON functions work the same whether the JSON document is stored in **varchar**, **nvarchar**, or the native **json** data type.
98+
JSON functions work the same way whether the JSON document is stored in **varchar**, **nvarchar**, or the native **json** data type.
7899

79100
## Remarks
80101

@@ -99,7 +120,7 @@ SET @jsonInfo = N'{
99120
}';
100121
```
101122

102-
The following table compares the behavior of `JSON_VALUE` in lax mode and in strict mode. For more info about the optional path mode specification (lax or strict), see [JSON Path Expressions in the SQL Database Engine](../../relational-databases/json/json-path-expressions-sql-server.md).
123+
The following table compares the behavior of `JSON_VALUE` in lax mode and in strict mode. For more info about the optional path mode specification (lax or strict), see [JSON path expressions in the SQL Database Engine](../../relational-databases/json/json-path-expressions-sql-server.md).
103124

104125
| Path | Return value in lax mode | Return value in strict mode | More info |
105126
| --- | --- | --- | --- |
@@ -118,7 +139,7 @@ The following table compares the behavior of `JSON_VALUE` in lax mode and in str
118139
The following example uses the values of the JSON properties `town` and `state` in query results. Since `JSON_VALUE` preserves the collation of the source, the sort order of the results depends on the collation of the `jsonInfo` column.
119140

120141
> [!NOTE]
121-
> (This example assumes that a table named `Person.Person` contains a `jsonInfo` column of JSON text, and that this column has the structure shown previously in the discussion of lax mode and strict mode. In the `AdventureWorks` sample database, the `Person` table doesn't in fact contain a `jsonInfo` column.)
142+
> This example assumes that a table named `Person.Person` contains a `jsonInfo` column of JSON text, and that this column has the structure shown previously in the discussion of lax mode and strict mode. In the `AdventureWorks` sample database, the `Person` table doesn't contain a `jsonInfo` column.
122143
123144
```sql
124145
SELECT FirstName,
@@ -175,5 +196,5 @@ date_value
175196

176197
## Related content
177198

178-
- [JSON Path Expressions in the SQL Database Engine](../../relational-databases/json/json-path-expressions-sql-server.md)
199+
- [JSON path expressions in the SQL Database Engine](../../relational-databases/json/json-path-expressions-sql-server.md)
179200
- [JSON data in SQL Server](../../relational-databases/json/json-data-sql-server.md)

0 commit comments

Comments
 (0)