© 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 ...

Get SQL Server Advanced Data Types: JSON, XML, and Beyond now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.