SQL Server where Clause on JSON Field

1k views Asked by At

I have a table

ID |  Start Date       | End Date          | Summary
---+-------------------+-------------------+----------------------------
1  | 2020-01-01T09:20  | 2020-01-01T09:30  | {"total":20,"totalError":10}
1  | 2020-01-02T09:20  | 2020-01-02T10:55  | {"total":10,"totalError":5}

I want to query where totalError > 0

Select * 
from runLog 
where Summary.totalError > 0

Is this possible?

1

There are 1 answers

0
GMB On BEST ANSWER

Use JSON_VALUE():

select * from runLog where json_value(summary, '$.totalError') > 0