Created
February 19, 2017 14:29
-
-
Save bertwagner/d10fcdb2c2e80506911f3469428726d3 to your computer and use it in GitHub Desktop.
Parsing JSON in pre-2016 SQL Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Let's compare how quick Phil Factor's JSON parsing function does against the new SQL 2016 functions | |
-- Phil's parseJSON function can be downloaded from https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/ | |
SELECT years.StringValue AS Year, makes.StringValue AS Make, models.StringValue AS Model FROM dbo.parseJSON(@cars) models | |
INNER JOIN dbo.parseJSON(@cars) years ON models.parent_ID = years.parent_ID | |
INNER JOIN dbo.parseJSON(@cars) makes ON models.parent_ID = makes.parent_ID | |
WHERE models.NAME = 'model' AND models.StringValue = 'Golf' AND years.NAME = 'year' AND makes.NAME = 'make' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment