1

Following is my script to get specific value(OldPTValue, NewPTValue) from table HistoryTracking.
I'm using OPENJSON but getting compatibility issue.
Is there any way to get data without using OPENJSON in sql server 2016?

SELECT 
    (
        SELECT [Number] 
        FROM OPENJSON( CHT.OldValues, '$.Employee' ) 
        WITH ([Number] NVARCHAR(25) '$.PaymentTerms')) AS OldPTValue, 
    (
        SELECT [Number] 
        FROM OPENJSON( CHT.NewValues, '$.Employee' ) 
        WITH ([Number] NVARCHAR(25) '$.PaymentTerms')
    ) AS NewPTValue,
    CHT.InsertedBy,
    CHT.InsertedDate 
FROM HistoryTracking CHT 
ORDER BY CHT.Employee, CHT.InsertedDate desc
Zohar Peled
  • 79,642
  • 10
  • 69
  • 121
Ritesh Gore
  • 49
  • 10
  • If you're experiencing compatibility problems your database's compatibility level. 2016 supports openjson but it requires compatibility level 130 or higher. – Zohar Peled Oct 27 '19 at 14:38

1 Answers1

1

I may be wrong, but it seems like that's what you may need there. https://learn.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-ver15