Download presentation
Presentation is loading. Please wait.
Published byMarcus Andrews Modified over 6 years ago
1
SQL Server 2016 JSON Support FOR Data Warehousing
Sifiso W. Ndlovu @mafiswana
2
Agenda Part I: Convert JSON Data to Relational
Part II: Convert Relational Data to JSON
3
Agenda JSON Editor
4
PART I: Convert JSON Data to Relational
5
What Is JSON JSON (JavaScript Object Notation) is a lightweight, readable format for structuring data It is based on a subset of JavaScript language It is used primarily to transmit data between a server and web application, as an alternative to XML It is easy for humans to read and write. It is easy for machines to parse and generate
6
What Is JSON Sample JSON document
7
Convert JSON Data to Relational
Requirement for Data Warehouse, T-SQL, Report development JSON by itself doesn’t not make sense to business or reporting tools
8
Convert JSON Data to Relational
Available functions ISJSON OPENJSON JSON_VALUE
9
Convert JSON Data to Relational
ISJSON
10
Convert JSON Data to Relational
ISJSON Validates JSON content Returns 1 for a valid JSON dataset and 0 for invalids Demo
11
Convert JSON Data to Relational
OPENJSON Works similar to OPENXML Takes in an object and convert its data into rows and columns Demo
12
Convert JSON Data to Relational
JSON_VALUE Extracts a scalar value from a JSON string Demo
13
PART II: Convert Relational Data to JSON
14
Convert Relational Data to JSON
Unsupported Data Types Spatial Geometry, Geography, CLR (Common Language Runtime) Supported Data Types SQL Server Data Type JSON Data Type char, nchar, varchar, nvarchar, date, datetime, datetime2, time, datetimeoffset, uniqueidentifier, money string int, bigint, float, decimal, numeric number Bit Boolean varbinary, binary, image, timestamp, rowversion BASE64-encoded string
15
Convert Relational Data to JSON
FOR JSON Clause AUTO Mode PATH Mode Options FOR JSON Clause ROOT INCLUDE_NULL_VALUES WITHOUT_ARRAY_WRAPPER
16
Convert Relational Data to JSON
FOR JSON Clause AUTO Mode simplest way to convert relational data into a JSON the structure of the JSON output is determined by a combination of the order of columns in your SELECT statement as well as the tables that are referenced by the SELECT statement Demo
17
Convert Relational Data to JSON
FOR JSON Clause PATH Mode Without a dot syntax With a dot syntax
18
Convert Relational Data to JSON
FOR JSON Clause PATH Mode Without a dot syntax When you are using it without a dot syntax, it works similar to the AUTO mode in that it will generate a JSON output based on the ordering of columns in your SELECT statement Demo
19
Convert Relational Data to JSON
FOR JSON Clause PATH Mode With a dot syntax Used to organise the JSON output into child arrays Demo
20
Convert Relational Data to JSON
Options FOR JSON Clause ROOT Used assign a label to the top-level array Demo
21
Convert Relational Data to JSON
Options FOR JSON Clause INCLUDE_NULL_VALUES Default behaviour when using FOR JSON clause is that NULL values will not be included in your JSON output This can be overridden by specifying the INCLUDE_NULL_VALUES option Demo
22
Convert Relational Data to JSON
Options FOR JSON Clause WITHOUT_ARRAY_WRAPPER Default every FOR JSON clause returns JSON data wrapped around square brackets To override this, use WITHOUT_ARRAY_WRAPPER option Demo
23
References www.SQLShack.com
24
Thank you to our sponsors
25
Questions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.