0

I need to search a string, for example 'RecId' in a column which has only JSON data.

First Cell JSON Data:

{ "AuditedFieldsAndRelationships": null, "AuditObjectChanges": false, "CalculatedRules": { "AuditHistoryDescription": { "Calculated": "Always", "CalculatedExpression": { "Description": null, "FieldRefs": ["RecId", "Rel_CIComponent_InstalledApplication_Name", "Rel_Software_Id", "Rel_Software_Name"] } } } }

Image:

enter image description here

Database: Microsoft SQL Server 2014

I got pretty similar problem solution in link but it is with respect to key

SELECT * FROM @table CROSS APPLY OPENJSON(Col,'$.Key') WHERE value ='SearchedString'

but it is showing error Invalid object name 'OPENJSON'

For that error, I tried the below solution given in link

SELECT compatibility_level FROM sys.databases WHERE name = 'DataBaseName';

But getting the below error:

enter image description here

Could someone help me out here.

Kms
  • 1,082
  • 2
  • 11
  • 27
  • 1
    `OPENJSON` was introduced with SQL Server 2016; you can't use it in 2014. If you really need to use `OPENJSON` then you need to upgrade. Otherwise you'll likely want to go down the CLR route, or use something else to read your JSON data. – Thom A Jun 25 '19 at 13:57
  • Compatibility level = 130 is sql server 2016. – M. Kanarkowski Jun 25 '19 at 13:57
  • 1
    JSON support was added in SQL Server 2016. Trying to use `OPENJSON` in 2014 is never going to work. The best you can do, without getting really complicated, is to just use `value LIKE '%String%'` if you don't need to be specific about where the value occurs. If you do, good luck. – Jeroen Mostert Jun 25 '19 at 13:57

0 Answers0