Simple JSON Examples

 DECLARE
    @JSON    NVARCHAR(MAX) =
        N'{"value":[{"AccountNumber":1003123456},{"AccountNumber":1004654321}]}';

SELECT *
FROM OPENJSON(@JSON, '$.value')
    WITH (
        AccountNumber    BIGINT
);


DECLARE
    @JSON    NVARCHAR(MAX) =
        N'[{"AccountNumber":1003123456},{"AccountNumber":1004654321}]';

SELECT *
FROM OPENJSON(@JSON)
    WITH (
        AccountNumber    BIGINT
);



Comments

Popular posts from this blog

Using sp_executesql with OPENQUERY

Executing Remote Queries Safely and Efficiently with sp_executesql