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
I may be wrong, but it seems like that's what you may need there. https://docs.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-ver15
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.