Import json file to sql table and then again export to json with some changes

Ashish Singh 1 Reputation point
2022-01-27T16:24:08.203+00:00

Hi, In a task I need to upload json file in sql table and then need to perform some updates on it and again recreate same json file from sql table. There should not be structure change in json while exporting from sql.
Attached sample json file.169112-sample-json.txt169106-sample-json.txt

Pls do the needful.

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,544 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LiHong-MSFT 10,046 Reputation points
    2022-01-28T06:56:25.457+00:00

    Hi @Ashish Singh
    To format/export query results as JSON, use the FOR JSON clause with the PATH or AUTO mode.
    Please refer to these two documents for more details:
    Format Query Results as JSON with FOR JSON (SQL Server)
    How to import/export JSON data using SQL Server 2016

    Best regards,
    LiHong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments