Skip to content

Instantly share code, notes, and snippets.

@bertwagner
Created February 12, 2017 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertwagner/009e2b581b0882da0695f79b3e1dda1d to your computer and use it in GitHub Desktop.
Save bertwagner/009e2b581b0882da0695f79b3e1dda1d to your computer and use it in GitHub Desktop.
TSQL Tuesday 87 Parsing JSON Pre 2016
SELECT
NAME,
StringValue,
ValueType
FROM
(
SELECT
[NAME],
StringValue,
ValueType,
LAG([NAME],1,0) OVER (ORDER BY element_id, sequenceNo, parent_ID) as PreviousKey
FROM
Sandbox.dbo.parseJSON(@WebsiteJson) -- This is Phil Factor's JSON parsing function: https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/
)d
WHERE
PreviousKey <> 'id'
and [NAME] = 'name'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment