Fix Error 13683 “Invalid JSON paths in JSON index” Due to Overlapping Paths in SQL Server

If you’re getting SQL Server error 13683 stating “Invalid JSON paths in JSON index“, it sounds like you could be specifying overlapping paths in your JSON index definition.

A JSON index cannot contain overlapping paths.

To fix this, remove the overlap from the specified paths that make up the index definition.

Example of Error

Here’s an example of code that causes the error:

CREATE JSON INDEX ix_bad
ON support_tickets (details)
FOR ('$.customer', '$.customer.id');

Output:

Msg 13683, Level 16, State 1, Line 1
Invalid JSON paths in JSON index.

Paths in the FOR clause can’t overlap. $.a and $.a.b can’t be specified together because $.a already recursively covers everything beneath it, and SQL Server raises an error if you try.

In the above example I’m specifying both $.customer and $.customer.id, which is what causes the error.

Solution

We can change the paths so that we explicitly state each path. This ensures that there are no overlapping siblings:

CREATE JSON INDEX ix_good
    ON support_tickets (details)
    FOR ('$.customer.id', '$.customer.name');

Output:

Commands completed successfully.

By the way, up to 128 levels of nesting are supported in the path, so you can get quite granular if required.