O'Reilly logo

SQL Server Advanced Data Types: JSON, XML, and Beyond by Peter A. Carter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Peter A. Carter  2018
Peter A. CarterSQL Server Advanced Data Typeshttps://doi.org/10.1007/978-1-4842-3901-8_7

7. Constructing JSON from T-SQL

Peter A. Carter1 
(1)
London, UK
 

Just as the FOR XML clause (see Chapter 3) can be used to construct XML documents from relational results sets, the FOR JSON clause can be used to construct JSON data from relational results sets. This is useful for exchanging data between SQL Server and traditional programming languages. Unlike FOR XML, however, FOR JSON only offers two modes: AUTO and PATH. This chapter discusses the use of the FOR JSON clause in both AUTO mode and PATH mode.

FOR JSON AUTO

FOR JSON AUTO is the simplest of the two FOR JSON modes. It can automatically nest JSON data, based on table joins, or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required