Read and parse JSON in T-SQL / SQL Server

access_time 2 years ago visibility95 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 at 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

Want to publish your article on Kontext?

Learn more

Kontext Column

Created for everyone to publish data, programming and cloud related articles.
Follow three steps to create your columns.


Learn more arrow_forward

More from Kontext

local_offer SSIS local_offer mssql

visibility 13104
thumb_up 0
access_time 7 years ago

SSIS (SQL Server Integration Service) provides a number of convenient tasks to enable data integration. Exporting data from database to Excel file is a common task in ETL (Extract, Transform, Load) projects. Constantly the users/customers may raise format request regarding the Excel extract. To ...

local_offer teradata local_offer t-sql local_offer mssql local_offer SQL local_offer SQL Server local_offer teradata-sql-query

visibility 4251
thumb_up 0
access_time 6 years ago

For Teradata developers, if you have no SQL Server installed, please go to the following link to download the SQL Server 2014 Expression Edition. http://www.microsoft.com/en-us/server-cloud/Products/sql-server-editions/sql-server-express.aspx It is easy to get started and free to use.

local_offer mssql local_offer t-sql

visibility 37
thumb_up 2
access_time 11 months ago

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

About column

Code snippets for various programming languages/frameworks.

rss_feed Subscribe RSS