In this picture, result column name(JSON_F52...) is auto-generated by SQL Server. How to change this name to unique name?
Format JSON Output Automatically with AUTO Mode (SQL Server) To format the output of the FOR JSON clause automatically based on the structure of the SELECT statement, specify the AUTO option.
In SQL Server you can use the FOR JSON clause in a query to format the results as JSON. When doing this, you must choose either the AUTO or the PATH option. This article contains examples of using the AUTO option.. Syntax. The syntax goes like this: SELECT ... (your query goes here) FOR JSON AUTO;
To format the output of the FOR JSON clause automatically based on the structure of the SELECT statement, specify the AUTO option. When you specify the AUTO option, the format of the JSON output is automatically determined based on the order of columns in the SELECT list and their source tables. You can't change this format.
If you’ve been using the JSON_MODIFY () function to modify JSON documents in SQL Server, you might be used to modifying the value part of a key/value property. But did you know that you can also modify the key part?
Can use this code:
SELECT (SELECT TOP 100 * FROM [Order] FOR JSON AUTO) AS ColumnName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With