如何将json格式转换为SQL

如何将json格式转换为SQL

本文介绍了如何将json格式转换为SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串@data它包含这个值

I have one string @data it is contained this value

@data=
{
	"dcrno": "20",
	"doctorcode": "di001",
	"salableitems":
	[
	{
	"itemcode":"it0001"
	},
	{
	"itemcode":"it0003"
	},
	{
	"itemcode":"it0002"
	}
	],

	"sample/promo/gift":
	[

	    {
	        "itemcode": "it001",
	        "itemqty": 10
	    },

	    {
	        "item code": "it002",
	        "itemqty": 2
	    },

	    {
	        "item code": "it009",
	        "itemqty": 7
	    }

	],
	"pob": "788",
	"not": "rajvalue",
	"time": "13:78:90"
}





喜欢



like

@data='@data=
{
	"dcrno": "20",
	"doctorcode": "di001",
	"salableitems":
	[
	{
	"itemcode":"it0001"
	},
	{
	"itemcode":"it0003"
	},
	{
	"itemcode":"it0002"
	}
	],

	"sample/promo/gift":
	[

	    {
	        "itemcode": "it001",
	        "itemqty": 10
	    },

	    {
	        "item code": "it002",
	        "itemqty": 2
	    },

	    {
	        "item code": "it009",
	        "itemqty": 7
	    }

	],
	"pob": "788",
	"not": "rajvalue",
	"time": "13:78:90"
}'





现在我想转换成列





喜欢



dcrno,doctorcode,salable,pob,note,time

喜欢这个..是吧有可能转换这个请帮我这样做



我尝试过:





now i want to convert into columns


like

dcrno,doctorcode,salable,pob,note,time
like this ..is it possible to convert likt this please help me to do that

What I have tried:

set @data=substring(@data,charindex(':',@data)),len(@data)-1)

推荐答案



这篇关于如何将json格式转换为SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 09:35