SQL Server读取Json值
dbo.GetJsonValue函数
框架提供了一个自定义函数 dbo.GetJsonValue,用来读取 Json 格式的字符串的内容
dbo.GetJsonValue(
@JsonString nvarchar(max), --需要读取有关信息的 Json 字符串
@KeyName nvarchar(256), --用于读取数据的键名称
@Index int = 1) --数组数据的索引值,默认为1,对象型数组才有效
RETURNS nvarchar(max)
例
| Creator |
|---|
| {“UserName”:”1000”,”UserDisplayName”:”张三”,”Entity”:null,”EntityID”:100,”Roles”:[“Administrators”]} |
PRINT dbo.GetJsonValue(Creator,'EntityID',DEFAULT)
输出:100
本文介绍了一种在SQLServer中使用自定义函数dbo.GetJsonValue读取Json格式字符串的方法。该函数通过指定键名和数组索引值来获取Json内容。

1万+

被折叠的 条评论
为什么被折叠?



