当前位置:Gxlcms > 数据库问题 > SqlServer 操作 Json

SqlServer 操作 Json

时间:2021-07-01 10:21:17 帮助过:4人阅读

ALTER TABLE Sales.SalesOrderHeader 2 ADD vCustomerName AS JSON_VALUE(Info,$.Customer.Name) 3 4 CREATE INDEX idx_soh_json_CustomerName 5 ON Sales.SalesOrderHeader(vCustomerName)

 

JSON 基本操作

{
    "name": "小明",
    "info": {
        "address": {
            "province": "河南省",
            "city": "郑州市",
            "district": "郑东新区"
        },
        "hobbies": [
            "篮球",
            "足球",
            "乒乓球"
        ]
    }
}
 1 -- 查询某一属性值
 2 SET @name = JSON_VALUE(@jsonInfo, $.name);
 3 SET @city = JSON_VALUE(@jsonInfo, $.info.address.city);
 4 
 5 -- 查询数组
 6 SET @hobbies = JSON_QUERY(@jsonInfo, $.info.hobbies);
 7 
 8 -- 增加属性 tempProp
 9 
10 SET @jsonInfo = JSON_MODIFY(@jsonInfo, tempProp, 1);
11 
12 -- 删除属性 tempProp
13 SET @jsonInfo = JSON_MODIFY(@jsonInfo, tempProp, null);

 

 

SqlServer 操作 Json

标签:tar   href   doc   判断   pen   适用于   存储   str   rop   

人气教程排行