Sqlserver Json
2022/2/16 19:11:44
本文主要是介绍Sqlserver Json,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
append3 字段的sql格式如下 [ {"ID":1,"Name":"身高、体重、血压","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":35,"Name":"肝功能八项","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":83,"Name":"血糖(餐后3小时)","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":100,"Name":"血脂四项","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":105,"Name":"肾功四项","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":106,"Name":"血常规(五分类)","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":162,"Name":"胸部正侧位片","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":202,"Name":"心电图","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":236,"Name":"乙肝两对半","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":338,"Name":"肝胆脾胰肾彩超","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null}, {"ID":379,"Name":"尿常规","MerchantsID":681,"MarketPrice":null,"CashPrice":null,"SettlePrice":null,"NormalPrice":null} ] SELECT OrderNo, ItemCombId, ItemCombName, ItemCombMarketPrice, ItemCombNormalPrice FROM T_ShopCart CROSS APPLY OPENJSON ( T_ShopCart.append3, '$' ) WITH ( ItemCombId VARCHAR ( 200 ) '$.ID', ItemCombName VARCHAR ( 200 ) '$.Name', ItemCombMarketPrice VARCHAR ( 200 ) '$.MarketPrice', ItemCombNormalPrice VARCHAR ( 200 ) '$.NormalPrice' ) where OrderNo ='22022021516184695133'
简单获取数组json 对象为多列查询效果
SELECT
OrderNo,
appjson.*
FROM
T_ShopCart CROSS APPLY OPENJSON ( T_ShopCart.append3, '$' ) as appjson
where OrderNo ='22022021516184695133'
OPENJSON ( T_ShopCart.append3, '$' ) WITH ( ItemCombId VARCHAR ( 200 ) '$.ID', ItemCombName VARCHAR ( 200 ) '$.Name', ItemCombMarketPrice VARCHAR ( 200 ) '$.MarketPrice', ItemCombNormalPrice VARCHAR ( 200 ) '$.NormalPrice' ) 命名获取对象中的值
官网资料 https://docs.microsoft.com/zh-cn/sql/relational-databases/json/json-data-sql-server?view=sql-server-ver15
这篇关于Sqlserver Json的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-21Vue3教程:新手入门到实践应用
- 2024-12-21VueRouter4教程:从入门到实践
- 2024-12-20Vue3项目实战:从入门到上手
- 2024-12-20Vue3项目实战:新手入门教程
- 2024-12-20VueRouter4项目实战:新手入门教程
- 2024-12-20如何实现JDBC和jsp的关系?-icode9专业技术文章分享
- 2024-12-20Vue项目中实现TagsView标签栏导航的简单教程
- 2024-12-20Vue3入门教程:从零开始搭建你的第一个Vue3项目
- 2024-12-20从零开始学习vueRouter4:基础教程
- 2024-12-20Vuex4课程:新手入门到上手实战全攻略