Tutorial by Examples

JSON_MODIFY function uses JSON text as input parameter, and modifies a value on the specified path using third argument: declare @json nvarchar(4000) = N'{"Id":1,"Name":"Toy Car","Price":34.99}' set @json = JSON_MODIFY(@json, '$.Price', 39.99) print @json -...
JSON_MODIFY has 'append' mode that appends value into array. declare @json nvarchar(4000) = N'{"Id":1,"Name":"Toy Car","Tags":["toy","game"]}' set @json = JSON_MODIFY(@json, 'append $.Tags', 'sales') print @json -- Output: {"Id&quot...
JSON_MODIFY function enables you to insert JSON objects into JSON text: declare @json nvarchar(4000) = N'{"Id":1,"Name":"Toy Car"}' set @json = JSON_MODIFY(@json, '$.Price', JSON_QUERY('{"Min":34.99,"Recommended":45.49}'))...
You can generate JSON object using standard SELECT query with FOR JSON clause and insert it into JSON text as third parameter: declare @json nvarchar(4000) = N'{"Id":17,"Name":"WWI"}' set @json = JSON_MODIFY(@json, '$.tables', (select name fr...
You can generate JSON object using standard SELECT query with FOR JSON clause and WITHOUT_ARRAY_WRAPPER option, and insert it into JSON text as a third parameter: declare @json nvarchar(4000) = N'{"Id":17,"Name":"WWI"}' set @json = JSON_MODIFY(@json, '$.table', ...

Page 1 of 1