Search
 
SCRIPT & CODE EXAMPLE
 

SQL

json_modify sql server

/*
1. Updates the value of a property in a JSON string and returns the 
updated JSON string.
2. SON_MODIFY returns an error if expression doesn't contain valid JSON.
*/

DECLARE @info NVARCHAR(100)='{"name":"John","skills":["C#","SQL"]}'
PRINT @info -- resutl : {"name":"John","skills":["C#","SQL"]}

-- Update name  
SET @info=JSON_MODIFY(@info,'$.name','Mike')
PRINT @info -- result: {"name":"Mike","skills":["C#","SQL"]}

-- add id
SET @info=JSON_MODIFY(@info,'$.id',1)
PRINT @info -- {"name":"Mike","skills":["C#","SQL"],"id":1}
Comment

PREVIOUS NEXT
Code Example
Sql :: postgresql like 
Sql :: postgresql inheritance 
Sql :: sql server get date of previous sunday 
Sql :: psql store procedure-return multiple table values 
Sql :: in sql 
Sql :: sql limit clause 
Sql :: how to declare variable date in mysql 
Sql :: oracle add attribute to table 
Sql :: sql create database statement 
Sql :: change column in mysql 
Sql :: cross join sl 
Sql :: how to increase the width of the screen in oracle 
Sql :: creashed table mysql 
Sql :: What is SQL data store? 
Sql :: clone row from another table mysql 
Sql :: equi joins in oracle 
Sql :: snowflake insert select 
Sql :: Concatenate columns in table 
Sql :: cast in sql server 
Sql :: postgres backup of table 
Sql :: character count sql 
Sql :: insert value to new table by joining 2 different tables 
Sql :: CREATE table schema using select 
Sql :: update or insert sql 
Sql :: between in sql 
Sql :: sql server in python 
Sql :: how to create notes in mysql 
Sql :: mysql workbench reset performance reports 
Sql :: query builder doctrien return sql 
Sql :: fonction stockée sql*plus 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =