Convert SQl Query into JSON Format in SQL Server:
(1) “SELECT” statement used for select records in table form database.
(2) Syntax of “SELECT” statement is:
SELECT column1, column2, … FROM table_name for JSON AUTO; |
(3) Let’s take an example to select records for “Vendor table” and show them in “JSON” format.
(4) Select the database in the SQL server and click on the “New Query” button as shown:
(5) After that new query editor open as shown:
(6) After doing the above steps, write query in the editor, as shown:
Source Code:
–//SQL data convert in JSON fomat. All fields show in json format Select * from dbo.[CRONUS India Ltd_$Vendor$d3c551dd-5903-4194-b153-04ced9d29a2c] for JSON AUTO –//SQL data convert in JSON fomat. All fields show in json format –//SQL data convert in JSON fomat. Particulats fields show in json format Select [No_], [P_A_N_ No_], [State Code] from dbo. [CRONUS India Ltd_$Vendor$d3c551dd-5903-4194-b153-04ced9d29a2c] for JSON AUTO –//SQL data convert in JSON fomat. All fields show in json format |
(7) After writing the query, then execute the query (Shortcut keys is F5) as as shown.