Skip to content

Commit b0aa90a

Browse files
authored
JSON path correction in example
The path to get JSON structure from 'skills' in Convert JSON collections to a rowset (example 2) was wrong and the alias (a) was remove for access a 'skills' column from outer apply
1 parent 1dc34ea commit b0aa90a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

docs/relational-databases/json/json-data-sql-server.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ FROM OPENJSON(@json)
155155
WITH (id int 'strict $.id',
156156
firstName nvarchar(50) '$.info.name', lastName nvarchar(50) '$.info.surname',
157157
age int, dateOfBirth datetime2 '$.dob',
158-
skills nvarchar(max) '$.skills' as json)
159-
outer apply openjson( a.skills )
160-
with ( skill nvarchar(8) '$' ) as b
158+
skills nvarchar(max) '$.info.skills' as json)
159+
outer apply openjson( skills )
160+
with ( skill nvarchar(8) '$' )
161161
```
162162
**skills** array is returned in the first `OPENJSON` as original JSON text fragment and passed to another `OPENJSON` function using `APPLY` operator. The second `OPENJSON` function will parse JSON array and return string values as single column rowset that will be joined with the result of the first `OPENJSON`.
163163
The result of this query is shown in the following table:

0 commit comments

Comments
 (0)