Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

JSON Data in T-SQL - SQL Server

RSS
Modified on Thu, Dec 05, 2019, 11:20 AM by Administrator Categorized as (Favorites), SQL Server

Overview

This article gives sample SQL for querying and parsing JSON data in SQL Server

Sample Data

The Before field looks like this

[{
    "Id": 392571,
    "CreatedOn": "2019-06-19T03: 00: 28"
}]

Sample Code

select top 10
     Id
    ,a.[Before]
    ,IdBefore       = json_value(a.[Before], '$[0]."Id"')
from 
    dbo.AuditLog a

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2019, Patrick Jasinski.