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:
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:
Could someone help me out here.