I wrote a stored procedure but this is not return any results. The query of the procedure work normally. But same query not return any result in the procedure.
Procedure:
ALTER proc [dbo].[GetValuesByDateRange](@dateFrom as datetime2, @dateTo as datetime2, @devId as varchar)
as
select *
from SensorValues
where AddDate between @dateFrom and @dateTo
and JSON_VALUE(Value,'$.DevId') = @devId
Query
select *
from SensorValues
where AddDate
between '2020-12-10 00:00:00' and '2020-12-14 00:00:00'
and JSON_VALUE(Value,'$.DevId') = '408414743'
Try to use Parenthesis between 2 Separate Conditions & also use varchar(max) instead of single varchar
ALTER proc [dbo].[GetValuesByDateRange](@dateFrom as datetime2, @dateTo as datetime2,
@devId as varchar(9))
as
select * from SensorValues
where (AddDate between @dateFrom and @dateTo)
and JSON_VALUE(Value,'$.DevId')= @devId
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.