From the course: Microsoft SQL Server 2016 Essential Training

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Storing JSON

Storing JSON

- [Instructor] In this section, we're going to talk about storing JSON data in a table in Microsoft SQL Server 2016. SQL Server does not provide a data type specifically for storing JSON, but because JSON is just text, we can store it in any of the fields designed to hold text. I've saved some code for you in your exercise files. If you want to copy just the top part of that into a new query window, and we'll see we're going to do some simple things. First, we'll create a table called JSONtest. That table will have one column, a column known as JsonData and we're using the data type nvarchar. That's a data type used for storing Unicode text. We then have a command to alter that table and add a constraint. The constraint will check to make sure that what is stored in the JsonData field actually is JSON. ISJSON is a new function in SQL Server 2016 that will return either true or false based on what we pass it will be evaluated as either valid JSON or invalid. We'll run this and we see…

Contents