当前位置:Gxlcms > 数据库问题 > MS SQL读取JSON数据

MS SQL读取JSON数据

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

@json_text NVARCHAR(MAX) SET @json_text = N { "DB Type": [ {"type":"AF","desc":"聚合函数(CLR)"}, {"type":"F","desc":"FOREIGN KEY 约束"}, {"type":"FN","desc":"SQL 标量函数"}, {"type":"FS","desc":"程序集(CLR)标量函数"}, {"type":"FT","desc":"程序集(CLR)表值函数"}, {"type":"RF","desc":"复制筛选过程"}, {"type":"IF","desc":"SQL 内联表值函数"}, {"type":"TF","desc":"SQL 表值函数"} ] }

 

读取JSON文本的key,value,type和type说明:

技术图片

技术图片
SELECT [key],[value],[type],[dbo].[svf_JSONDataType]([type]) AS data_type FROM  
OPENJSON (@json_text)  
Source Code

 

下面是真正把JSON转TABLE:

技术图片

 

技术图片
SELECT [type],[desc] FROM  
OPENJSON (@json_text ,$."DB Type")  
WITH
(
    [type] NVARCHAR(20) $.type,
    [desc] NVARCHAR(40) $.desc
)
Source Code

 

MS SQL读取JSON数据

标签:declare   需要   onclick   one   png   数据   img   说明   arch   

人气教程排行