Get your business online with free website builder (en)

How to convert SQL Query into JSON Format in SQL Server

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:

select database for selecting records in sql

(5) After that new query editor open as shown:

new query editor open in sql

(6) After doing the above steps, write query in the editor, as shown:

write query in the editor for JSON auto syntax

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.

execute the sql query by F5

AL Control Statements in Business Central
Use of SETRANGE and SETFILTER in Dynamics 365
How to use FOR-TO loop statement in Microsoft D365
Create Export to Excel Report in Business Central
Issue in Installing AL Symbol in VS editor [Solved]
OnAfterValidateEvent (Table) Trigger Event– Microsoft Docs

Leave a Reply