Sündmused
31. märts, 23 - 2. apr, 23
Suurim SQL, Fabric ja Power BI õppesündmus. 31. märts – 2. aprill. Kasutage koodi FABINSIDER, et säästa $400.
Registreeruge juba tänaSeda brauserit enam ei toetata.
Uusimate funktsioonide, turbevärskenduste ja tehnilise toe kasutamiseks võtke kasutusele Microsoft Edge.
Applies to:
SQL Server 2016 (13.x) and later
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics (serverless SQL pool only)
To include null values in the JSON output of the FOR JSON clause, specify the INCLUDE_NULL_VALUES option.
If you don't specify the INCLUDE_NULL_VALUES option, the JSON output doesn't include properties for values that are null in the query results.
The following example shows the output of the FOR JSON clause with and without the INCLUDE_NULL_VALUES option.
Without the INCLUDE_NULL_VALUES option | With the INCLUDE_NULL_VALUES option |
---|---|
{ "name": "John", "surname": "Doe" } |
{ "name": "John", "surname": "Doe", "age": null, "phone": null } |
Here's another example of a FOR JSON clause with the INCLUDE_NULL_VALUES option.
Query
SELECT name, surname
FROM emp
FOR JSON AUTO, INCLUDE_NULL_VALUES
Result
[{
"name": "John",
"surname": null
}, {
"name": "Jane",
"surname": "Doe"
}]
Märkus
Some of the video links in this section may not work at this time. Microsoft is migrating content formerly on Channel 9 to a new platform. We will update the links as the videos are migrated to the new platform.
For a visual introduction to the built-in JSON support in SQL Server and Azure SQL Database, see the following videos:
Sündmused
31. märts, 23 - 2. apr, 23
Suurim SQL, Fabric ja Power BI õppesündmus. 31. märts – 2. aprill. Kasutage koodi FABINSIDER, et säästa $400.
Registreeruge juba tänaKoolitus
Moodul
Combine multiple tables with JOINs in T-SQL - Training
Combine multiple tables with JOINs in T-SQL
Dokumentatsioon
Format query results as JSON with FOR JSON - SQL Server
Format query results as JSON, or export data from SQL Server as JSON, by adding the FOR JSON clause to a SELECT statement.
Remove Square Brackets from JSON - WITHOUT_ARRAY_WRAPPER Option - SQL Server
Remove Square Brackets from JSON - WITHOUT_ARRAY_WRAPPER Option
Format JSON Output Automatically with AUTO Mode - SQL Server
Format JSON Output Automatically with AUTO Mode (SQL Server)