sql server Json表达式解析函数
看到Json表达式, 在某些特殊情况下直接存json值。 下面取json表达式某项的值。
/*
取Json表达式值
参数: @code,@json
返回: @code 对应的值
eg.
@json='{"free":30,"first":1,"first fee":10,"per":30,"per fee":1.5}'
select dbo.UFJson('per',@json)
*/
create function [UFJson]
(
@code varchar(100),
@json nvarchar(2000))
returns nvarchar(500)
AS
BEGIN
declare @codeindex as int
declare @valueindex as int
declare @endindex as int
set @codeindex = charindex(@code,@json)
--没有找到code项
if (@codeindex = 0) return ''
set @valueindex = charindex(':',@json,@codeindex)
set @endindex = charindex(',',@json,@codeindex)
if (@endindex = 0) set @endindex = charindex('}',@json,@codeindex)
--格式不对 return ''
if (@valueindex = 0 or @endindex = 0) return ''
--正常返回
return substring(@json,@valueindex+1,@endindex-@valueindex-1)
END
GO
转载于:https://www.cnblogs.com/pnglooog/p/3262026.html
sql server Json表达式解析函数相关推荐
- SQL Server JSON:性能手册
目录 介绍 1. 数据类型 2. 存储 3. 压缩/解压 4. 压缩 5. 列存储 6. 创建JSON 7.检查JSON 8. JSONValue 9. OpenJson 10. 字符串拆分 11. ...
- sql与nosql_SQL Server JSON函数:NoSQL与关系世界之间的桥梁
sql与nosql In this article, we will explain what JSON is, what are the SQL Server JSON functions intr ...
- SQL Server 2016中的本机JSON支持
With the introduction of SQL Server 2016, Microsoft introduced many new features which had taken SQL ...
- SQL server中的类似Java的三目表达式及游标使用
运行环境:SQL server 2008R2 表达式:SELECT (CASE WHEN 1=1 THEN 'True' ELSE 'False' END) BEGINDECLARE @status ...
- 利用T-SQL动态定义重复SQL Server数据库表行
介绍 (Introduction) Lever T-SQL to handle duplicate rows in SQL Server database tables article highlig ...
- Oracle 9i与MS SQL Server 2000之比较连载五.zz
http://kb.cnblogs.com/a/1153156 Oracle 9i与MS SQL Server 2000之比较连载五 2008-04-14 18:13 四.Oracle中新的数据库对象 ...
- SQL Server 2016 JSON原生支持实例说明
原文:SQL Server 2016 JSON原生支持实例说明 背景 Microsoft SQL Server 对于数据平台的开发者来说越来越友好.比如已经原生支持XML很多年了,在这个趋势下,如今也 ...
- modify sql_在SQL Server中使用JSON_MODIFY()修改JSON数据
modify sql This article explores JSON_MODIFY() function to modify JSON Data in the SQL Server. 本文探讨了 ...
- 在SQL Server中将数据导出为XML和Json
BCP "SELECT DEPT_CODE,PARENTCODE FROM longshinewebhr.dbo.b01 where PARENTCODE like '10201%' FOR ...
最新文章
- SetWindowRgn注意点
- android应用中插入admob广告
- 【Python爬虫】写个爬虫爬取自己的博客,可以刷访问量
- 振动系统零频率和重频率问题探讨
- MySQL之Procedure(存储过程)和Function(函数)
- android 条码扫描控件,Android Zxing条码扫描自定义控件(附代码)
- SpringCloud Config 本地配置
- erlang在mac上安装
- c语言怎么求一个数的所有因数,【代码】求一个数的因数和、求优化、顺便也供新人参考算法...
- Android Design 1: Back键和Up键在App导航中的表现
- 常用工具类(初级中的初级)
- 管道|符与xargs命令
- 趣味项目—MyQQ机器人(二)关于python的pandas根据索引读写指定数据的方法实现签到功能
- 数据结构之冒泡排序的两个优化细节
- 55-将单链表原地逆置(三种方法)
- 小米3的卡槽,卡住了
- 关闭启动最新Photoshop 2021自动同步预设提示方法(临时)
- 在xml中定义excel的sheet_XML和Excel
- 图像风格迁移cvpr2020_CVPR 2020 论文大盘点-文本图像篇
- 【计组】字长、数据总线、地址总线