Hi friends, we will continue with FOR JSON clause in this blog and today we will learn formatting of query using FOR JSON clause mode with ROOT option in SQL Server 2016.

As per BOL we need to specify ROOT option in query, when we want to add a single, top level element to the JSON output of FOR JSON clause. JSON output will not have a root element until we specify the root option.

Syntax for ROOT option is:

ROOT [(‘RootName’)]

If we don’t provide the name of root element then it will take default value as root.

Let’s execute the below query to see the JSON ROOT option output:


Here in output we can see that Sales is the root element.









That’s all for the day folks.


Kapil Singh Kumawat

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook