Read and parse JSON in T-SQL / SQL Server

access_time 2 years ago visibility335 comment 0

JSON is commonly used in modern applications for data storage and transfers. Pretty much all programming languages provide APIs to parse JSON. 

From SQL Server 2016 on wards, JSON functions are commonly supported. You can use JSON_VALUE function to extract data from JSON columns.

Refer to the following page about more details of JSON functions:

JSON Functions (Transact-SQL)

Code snippet

WITH JSON_STR AS
(
select '{"Name":"A","Value":2}' as JSON_COLUMN
)
SELECT json_value(JSON_COLUMN, '$.Name') as Name,
json_value(JSON_COLUMN, '$.Value') as Value
from JSON_STR;
info Last modified by Raymond 2 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Follow Kontext

Get our latest updates on LinkedIn or Twitter.

Want to publish your article on Kontext?

Learn more

More from Kontext

visibility 3920
thumb_up 0
access_time 6 years ago

In this serial, I will compare Teradata SQL with T-SQL with samples provided. This is mainly prepared for SQL Server DBAs, Developers and other users to help them quickly master the common used SQLs in Teradata platform. Similar to T-SQL, Teradata SQL implements most part of the ANSI SQL with ...

visibility 41
thumb_up 2
access_time 2 years ago

In different databases, the syntax of selecting top N records are slightly different. They may also differ from ISO standards.

visibility 40
thumb_up 0
access_time 2 years ago

In Oracle database, you can select from dual table if you only want to return a one row result set. In many other databases, the query engine supports select directly from constant values without specifying a table name.