SlideShare a Scribd company logo
Introducing JSON
in MS SQL Server
Greg McMurray
Business Solutions Developer
Western Electricity Coordinating Council
Western Electricity Coordinating Council
• Non-profit to ensure the reliability of the western interconnection
• Approved Regional Entity by Federal Energy Regulatory Commission
• Create, monitor & enforce reliability standards
• Publish various models and independent perspective
• Covers 14 western states, 2 Canadian provinces and Baja Mexico
• We are hiring! https://www.wecc.biz/careers
Greg McMurray
• Worked in Aerospace, Branding & Marketing, Energy, Healthcare, Software
• Currently Business Solutions Developer atWECC
• Manager at Aritus Computer Services, L.L.C. for 18 years
• Active in many local user groups
• Find me online
• @goyuix
• https://www.linkedin.com/in/goyuix
• https://stackoverflow.com/cv/goyuix - top 3% of users
Hi! I am Greg – not Jason ↓
JSON? Who is Jason?
• “Discovered” by Douglas Crockford in 2001
• “JSON is XML for young people”
Scott Hanselman
DEVIntersection EU 2015
• Sample JSON:
{“User Group”:”Utah SQL Server Group”} ↑This is Scott - not Jason ↑
JavaScript Object Notation (JSON)
• What is JSON?
• Name-Value pairs
• Only 7 values: string, number, object, array, true, false, null
• Scalar values, objects and arrays - you can actually model a table or dataset quite nicely
• Number type: Supports both integer and floating point, but how they are implemented
is up to the parser.
• It is usually UTF-8 encoded – recommended to use NVARCHAR
Douglas Crockford – also not Jason↓
Want to Learn More About JSON?
• JSON.org is a great quick reference and starting place
• There are RFCs (4627 & 7159) and ECMA standards (404 & partly 262) as
published standards for data exchange
• Validation and schemas exist, not commonly used but are gaining in
popularity
Some JSON Gotchas & Quirks
• So what happens with dates or other complex types?
• Usually a convention of using one of the available types
• Date object might be represented by the ISO 8601 string
• How you do know if it was a string or date? Do you care?
• SQL Server JSON parser defaults to returning NVARCHAR typically
• JSON paths default to lax mode; strict mode changes behaviors
JSON Support in SQL Server
• Requires Compatibility Level 130 (SQL 2016)
• Some functions available at lower levels, but still require Server 2016 engine
• 120 might be the default even in new Azure SQL databases – you really need to check
• Available Functions
• ISJSON - more like IsValid JSON
• JSON_VALUE - for extracting scalar values
• JSON_MODIFY - like find / replace, but structured
• JSON_QUERY - useful for preventing SQL server from double escaping
• OPENJSON - treat JSON documents/objects/arrays as a table
• FOR JSON AUTO / PATH - convert query results to JSON document - similar to FOR XML
• Many functions can use / require a JSON path to identify data
• ProTip:You can use OPENROWSET to read saved JSON files
JSON Paths
• https://msdn.microsoft.com/en-us/library/mt577087.aspx
• String used in when calling various JSON functions
• Has a lax and strict mode; lax is the default
• Specify strict by including it at the start of your path, e.g. ‘strict $.Name’
• Strict mode changes:
• Generally raises errors on any possible parsing issues
• Error out on case-sensitivity issues rather than returning NULL
• Error out on missing keys for JSON_MODIFY, rather than adding them
• There is also an append mode used to add values to a JSON array
ISJSON
• https://msdn.microsoft.com/en-us/library/dn921896.aspx
• Returns 1 if the string contains valid JSON
• Examples:
• SELECT ISJSON('[1,2,3]')
• SELECT ISJSON('<tag>Not JSON</tag>')
• SELECT Id, Fragment FROM DocumentsWHERE ISJSON(Fragment) = 1
JSON_VALUE
• https://msdn.microsoft.com/en-us/library/dn921898.aspx
• Extracts a scalar value from a JSON string
• Examples:
• SELECT JSON_VALUE('{"Group":"SLC SQL UG"}', '$.Group')
• SELECT JSON_VALUE('{"Me":{"Name":"Greg"}}', '$.Me.Name')
JSON_QUERY
• https://msdn.microsoft.com/en-us/library/dn921884.aspx
• Extracts an object or an array from a JSON string
• JSON_VALUE returns scalar values; JSON_QUERY returns objects & arrays
• Examples:
• SELECT JSON_QUERY('{"a":[1,2,3]}', '$.a')
• SELECT JSON_QUERY('{"Me":{"Name":"Greg"}}', '$.Me')
JSON_MODIFY
• https://msdn.microsoft.com/en-us/library/dn921892.aspx
• Updates the value of a property in a JSON string and returns the new JSON
• Benefit: performs some validation and can safely replaces values
• Examples:
• SELECT JSON_MODIFY('{"Name":"Greg"}', '$.Name', 'Gregory')
• SELECT JSON_MODIFY('{"a":[1,2]}', 'append $.a', 3)
OPENJSON
• https://msdn.microsoft.com/en-us/library/dn921885.aspx
• Table-value function that parses JSON text and returns objects and properties as
rows and columns
• Requires COMPATIBILITY_LEVEL >= 130
• Supports defining a schema for JSON document
• Examples:
• SELECT * FROM OPENJSON('{"a":null,"b":1,"c":"2","d":[1,2],"e":{"f":6}}')
FOR JSON
• https://msdn.microsoft.com/en-us/library/ms173812.aspx
• Converts rows and columns to a JSON document
• Uses the FOR JSON syntax (similar to XML)
• Examples:
• SELECT name,object_id from sys.tables FOR JSON AUTO
Computed Columns
• Non-persisted data in the tables
• ProTip:You can build an index on a computed column
• This can be very useful for indexing into your JSON document
• Example:
ALTERTABLE [Table] ADD ColAS JSON_VALUE(JsonData, '$.Field')
Peeking Inside Pages –Table & Index
• Trace flags are your friend again: DBCCTRACEON(3604);
• DBCC IND('Database','dbo.Table',-1);
• DBCC PAGE('Database',FileNum,PagePID,3) WITHTABLERESULTS
• https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-using-
dbcc-page-and-dbcc-ind-to-find-out-if-page-splits-ever-roll-back/
Want to learn more?
• BertWagner
https://blog.bertwagner.com/
• SQL Server 2016 support for JSON
https://msdn.microsoft.com/en-us/library/dn921897.aspx
• JSON in SQL Server (4 Parts)
https://blogs.technet.microsoft.com/dataplatforminsider/2016/01/05/json-in-sql-
server-2016-part-1-of-4/
• JSON on MSDN Channel 9
https://channel9.msdn.com/Search?term=JSON
Questions and Discussion
• Did I introduce everything you hoped to learn today?
• Would you like any clarifications on something we covered?
• Share with us: How are you going to apply this is your world?
• Feel free to reach out to me online:
• Twitter: @goyuix
• LinkedIn: https://www.linkedin.com/in/goyuix

More Related Content

What's hot (20)

PDF
SQL vs. NoSQL Databases
Osama Jomaa
 
PPTX
Day 4 - Models
Barry Jones
 
PDF
SDEC2011 NoSQL Data modelling
Korea Sdec
 
PDF
Cassandra
Robert Koletka
 
KEY
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Alex Nguyen
 
PPTX
Modeling JSON data for NoSQL document databases
Ryan CrawCour
 
PDF
Elastic Search
Lukas Vlcek
 
PPTX
Introduction to mongo db
NexThoughts Technologies
 
PPTX
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
SpringPeople
 
PDF
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
 
PDF
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
Edureka!
 
PPTX
MongoDB basics & Introduction
Jerwin Roy
 
PPT
Jsp + My Sql
Ashwin K
 
PPTX
PostgreSQL - It's kind've a nifty database
Barry Jones
 
PPTX
NoSQL Tel Aviv Meetup#1: NoSQL Data Modeling
NoSQL TLV
 
PDF
Apache Any23 - Anything to Triples
Michele Mostarda
 
PPT
Mysql grand
Siddique Ibrahim
 
PPTX
Dataweave
Bhoopal Kante
 
SQL vs. NoSQL Databases
Osama Jomaa
 
Day 4 - Models
Barry Jones
 
SDEC2011 NoSQL Data modelling
Korea Sdec
 
Cassandra
Robert Koletka
 
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Alex Nguyen
 
Modeling JSON data for NoSQL document databases
Ryan CrawCour
 
Elastic Search
Lukas Vlcek
 
Introduction to mongo db
NexThoughts Technologies
 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
SpringPeople
 
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
 
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
Edureka!
 
MongoDB basics & Introduction
Jerwin Roy
 
Jsp + My Sql
Ashwin K
 
PostgreSQL - It's kind've a nifty database
Barry Jones
 
NoSQL Tel Aviv Meetup#1: NoSQL Data Modeling
NoSQL TLV
 
Apache Any23 - Anything to Triples
Michele Mostarda
 
Mysql grand
Siddique Ibrahim
 
Dataweave
Bhoopal Kante
 

Similar to Sql Server 2016 and JSON (20)

PDF
Native JSON Support in SQL2016
Ivo Andreev
 
PPTX
Azure SQL & SQL Server 2016 JSON
Davide Mauri
 
PPTX
SQL Server 2016 JSON
Davide Mauri
 
PPTX
JSON-SQLServer2016.pptx dgsdgdsgdsgdsgsdgdsgdsg
zmulani8
 
PPTX
Demystifying JSON in SQL Server
kristinferrier
 
PDF
JSON Support in DB2 for z/OS
Jane Man
 
PPTX
DBAs vs Developers: JSON in SQL Server - CBusPASS
Bert Wagner
 
PPTX
DBAs vs Developers - JSON in SQL Server
Bert Wagner
 
PPTX
JSON in SQL Server 2016
Bert Wagner
 
PPTX
DBAs vs Developers: JSON in SQL Server
Bert Wagner
 
PPTX
[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support
Alessandro Alpi
 
PPTX
JSON as a SQL Datatype
Robert Sell
 
PDF
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Jumping Bean
 
PDF
There is Javascript in my SQL
PGConf APAC
 
PPTX
BGOUG15: JSON support in MySQL 5.7
Georgi Kodinov
 
PPSX
Json in 18c and 19c
stewashton
 
PDF
Json in Postgres - the Roadmap
EDB
 
PDF
How to Use JSON in MySQL Wrong
Karwin Software Solutions LLC
 
PPTX
MySQL Rises with JSON Support
Okcan Yasin Saygılı
 
PPTX
Power JSON with PostgreSQL
EDB
 
Native JSON Support in SQL2016
Ivo Andreev
 
Azure SQL & SQL Server 2016 JSON
Davide Mauri
 
SQL Server 2016 JSON
Davide Mauri
 
JSON-SQLServer2016.pptx dgsdgdsgdsgdsgsdgdsgdsg
zmulani8
 
Demystifying JSON in SQL Server
kristinferrier
 
JSON Support in DB2 for z/OS
Jane Man
 
DBAs vs Developers: JSON in SQL Server - CBusPASS
Bert Wagner
 
DBAs vs Developers - JSON in SQL Server
Bert Wagner
 
JSON in SQL Server 2016
Bert Wagner
 
DBAs vs Developers: JSON in SQL Server
Bert Wagner
 
[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support
Alessandro Alpi
 
JSON as a SQL Datatype
Robert Sell
 
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Jumping Bean
 
There is Javascript in my SQL
PGConf APAC
 
BGOUG15: JSON support in MySQL 5.7
Georgi Kodinov
 
Json in 18c and 19c
stewashton
 
Json in Postgres - the Roadmap
EDB
 
How to Use JSON in MySQL Wrong
Karwin Software Solutions LLC
 
MySQL Rises with JSON Support
Okcan Yasin Saygılı
 
Power JSON with PostgreSQL
EDB
 
Ad

More from Greg McMurray (11)

PPTX
Power Platform Introduction - Utah PowerApps and Flow User Group
Greg McMurray
 
PPTX
SharePoint Search - August 2019 at Utah SharePoint User Group
Greg McMurray
 
PPTX
PowerShell Basics for Office Apps and Servers
Greg McMurray
 
PPTX
Introduction to SQL Server Graph DB
Greg McMurray
 
PPTX
Power BI Streaming Datasets - San Diego BI Users Group
Greg McMurray
 
PPTX
Dynamics 365 Web API - CRMUG April 2018
Greg McMurray
 
PPTX
SQL Server Temporal Tables
Greg McMurray
 
PPTX
Power BI Streaming Datasets
Greg McMurray
 
PPTX
Introduction to Microsoft Teams
Greg McMurray
 
PPTX
CRMUG Presentation on Dynamics CRM integration with SharePoint
Greg McMurray
 
PPTX
Real World Power Query for Excel and Power BI - SQL Saturday #576
Greg McMurray
 
Power Platform Introduction - Utah PowerApps and Flow User Group
Greg McMurray
 
SharePoint Search - August 2019 at Utah SharePoint User Group
Greg McMurray
 
PowerShell Basics for Office Apps and Servers
Greg McMurray
 
Introduction to SQL Server Graph DB
Greg McMurray
 
Power BI Streaming Datasets - San Diego BI Users Group
Greg McMurray
 
Dynamics 365 Web API - CRMUG April 2018
Greg McMurray
 
SQL Server Temporal Tables
Greg McMurray
 
Power BI Streaming Datasets
Greg McMurray
 
Introduction to Microsoft Teams
Greg McMurray
 
CRMUG Presentation on Dynamics CRM integration with SharePoint
Greg McMurray
 
Real World Power Query for Excel and Power BI - SQL Saturday #576
Greg McMurray
 
Ad

Recently uploaded (20)

PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 

Sql Server 2016 and JSON

  • 1. Introducing JSON in MS SQL Server Greg McMurray Business Solutions Developer Western Electricity Coordinating Council
  • 2. Western Electricity Coordinating Council • Non-profit to ensure the reliability of the western interconnection • Approved Regional Entity by Federal Energy Regulatory Commission • Create, monitor & enforce reliability standards • Publish various models and independent perspective • Covers 14 western states, 2 Canadian provinces and Baja Mexico • We are hiring! https://www.wecc.biz/careers
  • 3. Greg McMurray • Worked in Aerospace, Branding & Marketing, Energy, Healthcare, Software • Currently Business Solutions Developer atWECC • Manager at Aritus Computer Services, L.L.C. for 18 years • Active in many local user groups • Find me online • @goyuix • https://www.linkedin.com/in/goyuix • https://stackoverflow.com/cv/goyuix - top 3% of users Hi! I am Greg – not Jason ↓
  • 4. JSON? Who is Jason? • “Discovered” by Douglas Crockford in 2001 • “JSON is XML for young people” Scott Hanselman DEVIntersection EU 2015 • Sample JSON: {“User Group”:”Utah SQL Server Group”} ↑This is Scott - not Jason ↑
  • 5. JavaScript Object Notation (JSON) • What is JSON? • Name-Value pairs • Only 7 values: string, number, object, array, true, false, null • Scalar values, objects and arrays - you can actually model a table or dataset quite nicely • Number type: Supports both integer and floating point, but how they are implemented is up to the parser. • It is usually UTF-8 encoded – recommended to use NVARCHAR Douglas Crockford – also not Jason↓
  • 6. Want to Learn More About JSON? • JSON.org is a great quick reference and starting place • There are RFCs (4627 & 7159) and ECMA standards (404 & partly 262) as published standards for data exchange • Validation and schemas exist, not commonly used but are gaining in popularity
  • 7. Some JSON Gotchas & Quirks • So what happens with dates or other complex types? • Usually a convention of using one of the available types • Date object might be represented by the ISO 8601 string • How you do know if it was a string or date? Do you care? • SQL Server JSON parser defaults to returning NVARCHAR typically • JSON paths default to lax mode; strict mode changes behaviors
  • 8. JSON Support in SQL Server • Requires Compatibility Level 130 (SQL 2016) • Some functions available at lower levels, but still require Server 2016 engine • 120 might be the default even in new Azure SQL databases – you really need to check • Available Functions • ISJSON - more like IsValid JSON • JSON_VALUE - for extracting scalar values • JSON_MODIFY - like find / replace, but structured • JSON_QUERY - useful for preventing SQL server from double escaping • OPENJSON - treat JSON documents/objects/arrays as a table • FOR JSON AUTO / PATH - convert query results to JSON document - similar to FOR XML • Many functions can use / require a JSON path to identify data • ProTip:You can use OPENROWSET to read saved JSON files
  • 9. JSON Paths • https://msdn.microsoft.com/en-us/library/mt577087.aspx • String used in when calling various JSON functions • Has a lax and strict mode; lax is the default • Specify strict by including it at the start of your path, e.g. ‘strict $.Name’ • Strict mode changes: • Generally raises errors on any possible parsing issues • Error out on case-sensitivity issues rather than returning NULL • Error out on missing keys for JSON_MODIFY, rather than adding them • There is also an append mode used to add values to a JSON array
  • 10. ISJSON • https://msdn.microsoft.com/en-us/library/dn921896.aspx • Returns 1 if the string contains valid JSON • Examples: • SELECT ISJSON('[1,2,3]') • SELECT ISJSON('<tag>Not JSON</tag>') • SELECT Id, Fragment FROM DocumentsWHERE ISJSON(Fragment) = 1
  • 11. JSON_VALUE • https://msdn.microsoft.com/en-us/library/dn921898.aspx • Extracts a scalar value from a JSON string • Examples: • SELECT JSON_VALUE('{"Group":"SLC SQL UG"}', '$.Group') • SELECT JSON_VALUE('{"Me":{"Name":"Greg"}}', '$.Me.Name')
  • 12. JSON_QUERY • https://msdn.microsoft.com/en-us/library/dn921884.aspx • Extracts an object or an array from a JSON string • JSON_VALUE returns scalar values; JSON_QUERY returns objects & arrays • Examples: • SELECT JSON_QUERY('{"a":[1,2,3]}', '$.a') • SELECT JSON_QUERY('{"Me":{"Name":"Greg"}}', '$.Me')
  • 13. JSON_MODIFY • https://msdn.microsoft.com/en-us/library/dn921892.aspx • Updates the value of a property in a JSON string and returns the new JSON • Benefit: performs some validation and can safely replaces values • Examples: • SELECT JSON_MODIFY('{"Name":"Greg"}', '$.Name', 'Gregory') • SELECT JSON_MODIFY('{"a":[1,2]}', 'append $.a', 3)
  • 14. OPENJSON • https://msdn.microsoft.com/en-us/library/dn921885.aspx • Table-value function that parses JSON text and returns objects and properties as rows and columns • Requires COMPATIBILITY_LEVEL >= 130 • Supports defining a schema for JSON document • Examples: • SELECT * FROM OPENJSON('{"a":null,"b":1,"c":"2","d":[1,2],"e":{"f":6}}')
  • 15. FOR JSON • https://msdn.microsoft.com/en-us/library/ms173812.aspx • Converts rows and columns to a JSON document • Uses the FOR JSON syntax (similar to XML) • Examples: • SELECT name,object_id from sys.tables FOR JSON AUTO
  • 16. Computed Columns • Non-persisted data in the tables • ProTip:You can build an index on a computed column • This can be very useful for indexing into your JSON document • Example: ALTERTABLE [Table] ADD ColAS JSON_VALUE(JsonData, '$.Field')
  • 17. Peeking Inside Pages –Table & Index • Trace flags are your friend again: DBCCTRACEON(3604); • DBCC IND('Database','dbo.Table',-1); • DBCC PAGE('Database',FileNum,PagePID,3) WITHTABLERESULTS • https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-using- dbcc-page-and-dbcc-ind-to-find-out-if-page-splits-ever-roll-back/
  • 18. Want to learn more? • BertWagner https://blog.bertwagner.com/ • SQL Server 2016 support for JSON https://msdn.microsoft.com/en-us/library/dn921897.aspx • JSON in SQL Server (4 Parts) https://blogs.technet.microsoft.com/dataplatforminsider/2016/01/05/json-in-sql- server-2016-part-1-of-4/ • JSON on MSDN Channel 9 https://channel9.msdn.com/Search?term=JSON
  • 19. Questions and Discussion • Did I introduce everything you hoped to learn today? • Would you like any clarifications on something we covered? • Share with us: How are you going to apply this is your world? • Feel free to reach out to me online: • Twitter: @goyuix • LinkedIn: https://www.linkedin.com/in/goyuix