How to Fix “Invalid object name ‘OPENJSON’.” in SQL Server

If you encounter error Msg 208, Level 16 “Invalid object name ‘OPENJSON’.”, you are probably trying to use the OPENJSON() function on a database with a compatibility level of less than 130.

OPENJSON() is only available under compatibility level 130 or higher.

To fix this, either increase the compatibility level of your database to 130 or higher, or change to a database that already has the appropriate compatibility level.

Read more

JSON_STORAGE_FREE() – Find Out How Much Storage Space was Freed Up After an Update of a JSON Document in MySQL

In MySQL, the JSON_STORAGE_FREE() function shows how much storage space was freed up after a JSON Document was updated.

For a JSON column value, it shows how much storage space was freed in its binary representation after it was updated in place using JSON_SET(), JSON_REPLACE(), or JSON_REMOVE().

For a JSON document (or a string which can be parsed as one), this function returns 0.

Read more

JSON_STORAGE_SIZE() – Find the Storage Size of a JSON Document in MySQL

In MySQL, the JSON_STORAGE_SIZE() function returns the number of bytes used to store the binary representation of a JSON document.

You provide the JSON document as an argument.

When the argument is a JSON column, this function returns the space used to store the JSON document as it was inserted into the column, prior to any partial updates that may have been performed on it afterwards.

When the argument is a string, the function returns the amount of storage space in the JSON binary representation that is created by parsing the string as JSON and converting it to binary.

Read more

JSON_SEARCH() – Find the Path to a String in a JSON Document in MySQL

In MySQL, the JSON_SEARCH() function returns the path to a given string in a JSON document.

You provide the JSON document as an argument to the function. You also provide the argument that determines the actual string to search (including any escape characters), as well as a keyword to indicate whether to return the path of all instances or just one.

Read more

JSON_KEYS() – Return the Keys from a JSON Object in MySQL

In MySQL, the JSON_KEYS() function returns keys from the top level value of a JSON object. The keys are returned as a JSON array, or, if a path argument is given, the top-level keys from the selected path.

You provide the JSON document as an argument to the function.

You can also (optionally) provide a second argument to specify where the “top-level” path starts from within the JSON document.

Read more

JSON_EXTRACT() – Return Data from a JSON Document in MySQL

In MySQL, the JSON_EXTRACT() function returns data from a JSON document. The actual data returned is determined by the path you provide as an argument.

You provide the JSON document as the first argument, followed by the path of the data to return. You can also provide multiple paths to return data from multiple places in the document.

Read more