Working with JSON data in SQL queries
So far, we have focused on how to build JSON-formatted results from the queries we have been creating. In this section, we are going to explore how to work with JSON data in our queries. We will look at how to discover and validate our JSON data, followed by extracting and modifying that information. We will wrap this section up by building out a query to convert JSON data into tabular data with a relationship to relational data as well.
Discovering JSON data in SQL Server
There are two primary functions we will work with within SQL Server to discover and validate JSON data. These functions confirm that we are working with JSON data and that the data we are looking at exists in the JSON document.
ISJSON
ISJSON is used to evaluate a variable, expression, or field in a SQL query to determine that the structure of that data is properly formatted JSON. In our example, we will investigate the CustomerOrderHistory
field in our CustomerOrders...