|
| 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) |
0 commit comments