如何检查json字符串中的数据是否存在于表中? [英] How to check data with in a json string exists or not exists in a table ?

查看:86
本文介绍了如何检查json字符串中的数据是否存在于表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表中存在或不存在的json字符串中检查数据。

我传递的json字符串包含引用号:我使用的是Sql server 2008.



json字符串如下:

{Login_Id:alex.maker,User_Name:Samuel Jacob,Email_Id:Samuel.Jacob@nestgroup.net,模式:M,Corporate_ID :NeST,Establishment_ID:12345678911830098344779998855552331,Reference_No:IB120219100105}'



我尝试过:



尝试如下:

I want to check data with in a json string exists or not exists in a table .
I am passing a json string which contains reference no: I am using Sql server 2008.

json string is as below:
{"Login_Id":"alex.maker","User_Name":"Samuel Jacob","Email_Id":"Samuel.Jacob@nestgroup.net","Mode":"M","Corporate_ID":"NeST","Establishment_ID":"12345678911830098344779998855552331","Reference_No":"IB120219100105"}'

What I have tried:

Tried as below:

declare @ReferenceNo varchar(max) ='IB120219100105'
set @ReferenceNo='{"Login_Id":"alex.maker","User_Name":"Samuel Jacob","Email_Id":"Samuel.Jacob@nestgroup.net","Mode":"M","Corporate_ID":"NeST","Establishment_ID":"12345678911830098344779998855552331","Reference_No":"IB120219100105"}'

SELECT * FROM User_Sync_Log WHERE  
SyncLogRequest LIKE   '%Reference_No": "%'+@ReferenceNo+'"%'



但没有数据


But no data coming

推荐答案

2016年之前ere是没有内置的你可以使用...你必须在SQL中编写自己的JSON解析函数...

这里有一个很好的示例:

在SQL Server中使用JSON字符串 - 简单谈话 [ ^ ]
Before 2016 there is nothing built in you can use... You have to write your own JSON parsing functions in SQL...
There is a good sample here to start with:
Consuming JSON Strings in SQL Server - Simple Talk[^]


这篇关于如何检查json字符串中的数据是否存在于表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆