WITH TBL AS
(
    SELECT 1 AS ID, 'PARK'   AS NAME, 45 AS AGE
    UNION ALL
    SELECT 2 AS ID, 'HWANG'  AS NAME, 41 AS AGE
    UNION ALL
    SELECT 3 AS ID, 'KIM'    AS NAME, 23 AS AGE
    UNION ALL
    SELECT 4 AS ID, 'MOON'   AS NAME, 34 AS AGE
)
SELECT  NAME, AGE
FROM TBL
FOR JSON AUTO;

JSON_F52E2B61-18A1-11d1-B105-00805F49916B                                                            |
-----------------------------------------------------------------------------------------------------|
[{"NAME":"PARK","AGE":45},{"NAME":"HWANG","AGE":41},{"NAME":"KIM","AGE":23},{"NAME":"MOON","AGE":34}]|







WITH TBL AS
(
    SELECT 1 AS ID, 'PARK'   AS NAME, 45 AS AGE
    UNION ALL
    SELECT 2 AS ID, 'HWANG'  AS NAME, 41 AS AGE
    UNION ALL
    SELECT 3 AS ID, 'KIM'    AS NAME, 23 AS AGE
    UNION ALL
    SELECT 4 AS ID, 'MOON'   AS NAME, 34 AS AGE
)
SELECT  NAME, AGE
FROM TBL
FOR JSON AUTO , WITHOUT_ARRAY_WRAPPER;

JSON_F52E2B61-18A1-11d1-B105-00805F49916B                                                          |
---------------------------------------------------------------------------------------------------|
{"NAME":"PARK","AGE":45},{"NAME":"HWANG","AGE":41},{"NAME":"KIM","AGE":23},{"NAME":"MOON","AGE":34}|







WITH TBL AS
(
    SELECT 1 AS ID, 'PARK'   AS NAME, 45 AS AGE
    UNION ALL
    SELECT 2 AS ID, 'HWANG'  AS NAME, 41 AS AGE
    UNION ALL
    SELECT 3 AS ID, 'KIM'    AS NAME, 23 AS AGE
    UNION ALL
    SELECT 4 AS ID, 'MOON'   AS NAME, 34 AS AGE
)
SELECT  ID
,       (SELECT NAME, AGE FOR JSON PATH, WITHOUT_ARRAY_WRAPPER) AS VALUE
FROM TBL;


ID|VALUE                    |
--|-------------------------|
 1|{"NAME":"PARK","AGE":45} |
 2|{"NAME":"HWANG","AGE":41}|
 3|{"NAME":"KIM","AGE":23}  |
 4|{"NAME":"MOON","AGE":34} |








-- JSON String을 Row level JSON String으로
DECLARE @json NVARCHAR(MAX)
SET @json = (SELECT NAME, AGE 
             FROM  (SELECT 1 AS ID, 'PARK'   AS NAME, 45 AS AGE
                    UNION ALL
                    SELECT 2 AS ID, 'HWANG'  AS NAME, 41 AS AGE
                    UNION ALL
                    SELECT 3 AS ID, 'KIM'    AS NAME, 23 AS AGE
                    UNION ALL
                    SELECT 4 AS ID, 'MOON'   AS NAME, 34 AS AGE) TBL
             FOR JSON AUTO)
             
SELECT value
FROM OPENJSON(@json);




value                    |
-------------------------|
{"NAME":"PARK","AGE":45} |
{"NAME":"HWANG","AGE":41}|
{"NAME":"KIM","AGE":23}  |
{"NAME":"MOON","AGE":34} |