How to add root node to JSON output in MSSQL?

MSSQL 2016 has a new feature where you can return the data as JSON output format and also add root node to JSON output in MSSQL. Checkout MSSQL Built-In JSON support for more details.

The FOR JSON returns the JSON data when it is used with the select query, however, the JSON data will not have the root node.

Output in JSON format

As we saw in the earlier example the JSON output does not have the root node. Now in this example lets see how to return the data output with root node using MSSQL query.

SQL Query to add root node to JSON output in MSSQL

Output in JSON format with ROOT node as info

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.