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.
© Peter A. Carter 2018
Peter A. CarterSQL Server Advanced Data Typeshttps://doi.org/10.1007/978-1-4842-3901-8_77. Constructing JSON from T-SQL
Peter A. Carter1
(1)
London, UK
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.