JSON extract text
Returns the selected JSON value as text (nvarchar), from a document given as text or binary JSON.
Category: extraction
SQL symbol: ->>
Syntax
sql
<document> ->> <path>Parameters
<document>— The JSON document to read from. Acceptsnvarchar,varbinary,varchar,variant.<path>— The key or path to select, in the same spellings->accepts. A path that is not present gives NULL. Acceptsnvarchar,varbinary,varchar.
Returns
Examples
sql
SELECT '{"name": "Earth", "moons": 1}' ->> 'name';Earth
Signatures
nvarchar ->> nvarchar→ nvarcharnvarchar ->> varbinary→ nvarcharnvarchar ->> varchar→ nvarcharvarbinary ->> nvarchar→ nvarcharvarbinary ->> varbinary→ nvarcharvarbinary ->> varchar→ nvarcharvarchar ->> nvarchar→ nvarcharvarchar ->> varbinary→ nvarcharvarchar ->> varchar→ nvarcharvariant ->> nvarchar→ nvarcharvariant ->> varchar→ nvarchar
Notes
Use ->> when the value is going to be compared with a string literal: -> would leave it JSON-quoted and the comparison would not match.