Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change JSON Column name in sql server 2016

Tags:

sql

sql-server

How can I change the column name "JSON_F52......" to Any(e.g. SalesOrder)

enter image description here

like image 752
Furqan Misarwala Avatar asked Nov 08 '17 13:11

Furqan Misarwala


People also ask

How do I update a JSON column in SQL?

You can use the UPDATE statement to modify values of a JSON column in the SET clause. You can only update the JSON column, not individual portions of the JSON instance. Also, when referencing a JSON column in its entirety, the input format is the same as the INSERT statement. MERGE.

How do I rename a column in SQL Server?

Select and right-click on a table or a column you want to rename and click Rename. Enter a new name by over writing on existing name. Go to the file menu and click Save.

How do I rename a column in SQL Server 2016?

Use SQL Server Management StudioIn Object Explorer, right-click the table in which you want to rename columns and choose Rename. Type a new column name.

Does SQL Server 2016 support JSON?

Now, SQL Server also supports the JSON format. There is no specific data type for JSON SQL Server like XML. We need to use NVARCHAR when we interact with JSON. There are many built-in functions available with SQL Server 2016, such as ISJSON, JSON_VALUE, JSON_QUERY, JSON_MODIFY, OPENJSON, and FOR JSON.


1 Answers

Wrap your json building SELECT in another SELECT:

SELECT (
      SELECT SalesOrderNumber AS 'Order.Number',
             OrderDate AS 'Order.Date'
        FROM Sales.SalesOrderHeader
         FOR JSON PATH
) AS SalesOrder
like image 118
Michal D. Avatar answered Sep 20 '22 21:09

Michal D.