Skip to content

Commit 6f23858

Browse files
Update JSON functions for SQL Server 2025 (#35473)
* Add sys.json_indexes and sys.json_index_paths documentation; update JSON_VALUE syntax * pencil edit Updated section header from 'D' to 'E' for clarity. --------- Co-authored-by: Stacy Chambers <102548089+Stacyrch140@users.noreply.github.com>
1 parent 3d9ba31 commit 6f23858

11 files changed

Lines changed: 605 additions & 223 deletions
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
title: "sys.json_index_paths (Transact-SQL)"
3+
description: "sys.json_index_paths contains the SQL/JSON paths for a JSON index."
4+
author: uc-msft
5+
ms.author: umajay
6+
ms.reviewer: mikeray, randolphwest
7+
ms.date: 10/27/2025
8+
ms.service: sql
9+
ms.subservice: system-objects
10+
ms.topic: reference
11+
f1_keywords:
12+
- "sys.json_index_paths"
13+
- "json_index_paths"
14+
- "sys.json_index_paths_TSQL"
15+
- "json_index_paths_TSQL"
16+
helpviewer_keywords:
17+
- "sys.json_index_paths catalog view"
18+
dev_langs:
19+
- TSQL
20+
monikerRange: "=sql-server-ver17 || =sql-server-linux-ver17"
21+
---
22+
23+
# sys.json_index_paths (Transact-SQL)
24+
25+
[!INCLUDE [SQL Server 2025](../../includes/applies-to-version/sqlserver2025.md)]
26+
27+
Contains the SQL/JSON paths for a JSON index. If the `CREATE JSON INDEX` statement doesn't define a `sql_json_path`, this catalog view contains one row with a root SQL/JSON path `S` for that index.
28+
29+
| Column name | Data type | Description |
30+
| --- | --- | --- |
31+
| **object_id** | **int** | ID of table with JSON column. |
32+
| **index_id** | **int** | ID of JSON index. |
33+
| **path** | **varchar(8000)** | SQL/JSON path. Collation of the path column is fixed to `Latin1_General_100_BIN2_UTF8`. |
34+
35+
## Permissions
36+
37+
[!INCLUDE [ssCatViewPerm](../../includes/sscatviewperm-md.md)] For more information, see [Metadata visibility configuration](../security/metadata-visibility-configuration.md).
38+
39+
## Examples
40+
41+
### A. JSON index with no paths
42+
43+
The following example returns JSON indexes for the table `dbo.Customers`. The JSON index is created without specifying any SQL/JSON path.
44+
45+
```sql
46+
DROP TABLE IF EXISTS dbo.Customers;
47+
48+
CREATE TABLE dbo.Customers
49+
(
50+
customer_id INT IDENTITY PRIMARY KEY,
51+
customer_info JSON NOT NULL
52+
);
53+
54+
CREATE JSON INDEX CustomersJsonIndex
55+
ON dbo.Customers (customer_info);
56+
57+
INSERT INTO dbo.Customers (customer_info)
58+
VALUES ('{"name":"customer1", "email": "customer1@example.com", "phone":["123-456-7890", "234-567-8901"]}');
59+
60+
SELECT object_id,
61+
index_id,
62+
path
63+
FROM sys.json_index_paths
64+
WHERE object_id = OBJECT_ID('dbo.Customers');
65+
```
66+
67+
### B. JSON index for a specific path
68+
69+
The following example returns JSON indexes for the table `dbo.Customers`. The JSON index is created for a specific SQL/JSON path `$.phone`.
70+
71+
```sql
72+
DROP TABLE IF EXISTS dbo.Customers;
73+
74+
CREATE TABLE dbo.Customers
75+
(
76+
customer_id INT IDENTITY PRIMARY KEY,
77+
customer_info JSON NOT NULL
78+
);
79+
80+
CREATE JSON INDEX CustomersJsonIndex
81+
ON dbo.Customers (customer_info)
82+
FOR ('$.phone') WITH (OPTIMIZE_FOR_ARRAY_SEARCH = ON);
83+
84+
INSERT INTO dbo.Customers (customer_info)
85+
VALUES ('{"name":"customer1", "email": "customer1@example.com", "phone":["123-456-7890", "234-567-8901"]}');
86+
SELECT object_id,
87+
index_id,
88+
path
89+
FROM sys.json_index_paths
90+
WHERE object_id = OBJECT_ID('dbo.Customers');
91+
```
92+
93+
### C. JSON index for multiple paths
94+
95+
The following example returns JSON indexes for the table `dbo.Customers`. The JSON index is created for multiple SQL/JSON paths `$.name` and `$.email`.
96+
97+
```sql
98+
DROP TABLE IF EXISTS dbo.Customers;
99+
100+
CREATE TABLE dbo.Customers
101+
(
102+
customer_id INT IDENTITY PRIMARY KEY,
103+
customer_info JSON NOT NULL
104+
);
105+
106+
CREATE JSON INDEX CustomersJsonIndex
107+
ON dbo.Customers (customer_info)
108+
FOR ('$.name', '$.email');
109+
110+
INSERT INTO dbo.Customers (customer_info)
111+
VALUES ('{"name":"customer1", "email": "customer1@example.com", "phone":["123-456-7890", "234-567-8901"]}');
112+
113+
SELECT object_id,
114+
index_id,
115+
path
116+
FROM sys.json_index_paths
117+
WHERE object_id = OBJECT_ID('dbo.Customers');
118+
```
119+
120+
## Related content
121+
122+
- [Object catalog views (Transact-SQL)](object-catalog-views-transact-sql.md)
123+
- [System catalog views (Transact-SQL)](catalog-views-transact-sql.md)
124+
- [sys.indexes (Transact-SQL)](sys-indexes-transact-sql.md)
125+
- [sys.json_indexes (Transact-SQL)](sys-json-indexes-transact-sql.md)
126+
- [CREATE JSON INDEX (Transact-SQL)](../../t-sql/statements/create-json-index-transact-sql.md)
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: "sys.json_indexes (Transact-SQL)"
3+
description: sys.json_indexes contains a row per json index.
4+
author: uc-msft
5+
ms.author: umajay
6+
ms.reviewer: mikeray, randolphwest
7+
ms.date: 10/27/2025
8+
ms.service: sql
9+
ms.subservice: system-objects
10+
ms.topic: reference
11+
f1_keywords:
12+
- "sys.json_indexes"
13+
- "json_indexes"
14+
- "sys.json_indexes_TSQL"
15+
- "json_indexes_TSQL"
16+
helpviewer_keywords:
17+
- "sys.json_indexes catalog view"
18+
dev_langs:
19+
- TSQL
20+
monikerRange: "=sql-server-ver17 || =sql-server-linux-ver17"
21+
---
22+
23+
# sys.json_indexes (Transact-SQL)
24+
25+
[!INCLUDE [SQL Server 2025](../../includes/applies-to-version/sqlserver2025.md)]
26+
27+
Contains a row per json index.
28+
29+
| Column name | Data type | Description |
30+
| --- | --- | --- |
31+
| **\<inherited columns>** | | Inherits columns from [sys.indexes](sys-indexes-transact-sql.md). |
32+
| **optimize_for_array_search** | **bit** | Indicates that array search optimization is enabled for JSON index. 1 = Array search optimization is enabled for JSON index.<br />0 = Array search optimization isn't enabled for JSON indexes. Default is 0. |
33+
34+
## Permissions
35+
36+
[!INCLUDE [ssCatViewPerm](../../includes/sscatviewperm-md.md)] For more information, see [Metadata visibility configuration](../security/metadata-visibility-configuration.md).
37+
38+
## Examples
39+
40+
### A. JSON index without array search optimization
41+
42+
The following example returns JSON indexes for the table `dbo.Customers`. The JSON index is created without the array search optimization option enabled.
43+
44+
```sql
45+
DROP TABLE IF EXISTS dbo.Customers;
46+
47+
CREATE TABLE dbo.Customers
48+
(
49+
customer_id INT IDENTITY PRIMARY KEY,
50+
customer_info JSON NOT NULL
51+
);
52+
53+
CREATE JSON INDEX CustomersJsonIndex
54+
ON dbo.Customers (customer_info);
55+
56+
INSERT INTO dbo.Customers (customer_info)
57+
VALUES ('{"name":"customer1", "email": "customer1@example.com", "phone":["123-456-7890", "234-567-8901"]}');
58+
59+
SELECT object_id,
60+
index_id,
61+
optimize_for_array_search
62+
FROM sys.json_indexes AS ji
63+
WHERE object_id = OBJECT_ID('dbo.Customers');
64+
```
65+
66+
### B. JSON index with array search optimization
67+
68+
The following example returns JSON indexes for the table `dbo.Customers`. The JSON index is created with the array search optimization option enabled.
69+
70+
```sql
71+
DROP TABLE IF EXISTS dbo.Customers;
72+
73+
CREATE TABLE dbo.Customers
74+
(
75+
customer_id INT IDENTITY PRIMARY KEY,
76+
customer_info JSON NOT NULL
77+
);
78+
79+
CREATE JSON INDEX CustomersJsonIndex
80+
ON dbo.Customers (customer_info) WITH (OPTIMIZE_FOR_ARRAY_SEARCH = ON);
81+
82+
INSERT INTO dbo.Customers (customer_info)
83+
VALUES ('{"name":"customer1", "email": "customer1@example.com", "phone":["123-456-7890", "234-567-8901"]}');
84+
85+
SELECT object_id,
86+
index_id,
87+
optimize_for_array_search
88+
FROM sys.json_indexes AS ji
89+
WHERE object_id = OBJECT_ID('dbo.Customers');
90+
```
91+
92+
## Related content
93+
94+
- [Object catalog views (Transact-SQL)](object-catalog-views-transact-sql.md)
95+
- [System catalog views (Transact-SQL)](catalog-views-transact-sql.md)
96+
- [sys.indexes (Transact-SQL)](sys-indexes-transact-sql.md)
97+
- [sys.json_index_paths (Transact-SQL)](sys-json-index-paths-transact-sql.md)
98+
- [CREATE JSON INDEX (Transact-SQL)](../../t-sql/statements/create-json-index-transact-sql.md)

0 commit comments

Comments
 (0)