Converting JSON to table in SQL Server 2016 Converting JSON to table in SQL Server 2016 json json

Converting JSON to table in SQL Server 2016


I found a Microsoft page that actually solves the problem.

Here is how the query should look like:

SELECT *  FROM OPENJSON(@_l_Table_Data)  WITH (    Formal_Round_Method        NVARCHAR(16)    '$.Formal_Round_Method'               ,            Public_Round_Method        NVARCHAR(16)    '$.Public_Round_Method'               ,            Formal_Precision           INT             '$.Formal_Precision'                  ,            Public_Precision           INT             '$.Public_Precision'                  ,            Formal_Significant_Digits  INT             '$.Formal_Significant_Digits'         ,            Public_Significant_Digits  INT             '$.Public_Significant_Digits'         ,            General_Comment            NVARCHAR(MAX)   '$.General_Comment'   AS JSON                    ) ;

So, you need to add AS JSON at the end of the column definition and (God knows why) the type MUST be NVARCHAR(MAX).

Very simple indeed!!!