I am trying to cast/ convert varchar to a numeric value. I have done this succesfuly when I eval the lower range, however I get an error when I do the upper range.

this is my evaluation section that works.

isnull(cast(measurmentdata.measvalue as numeric),0) < productinfo.lowerrange

however when I try to test to see if it is above the upper range it throws an error

isnull(cast(measurmentdata.measvalue as numeric),0)  >  productinfo.upperrange

I have tried not between as well. while it does not return any errors it does not correctly test for > or <

isnull(cast(measurmentdata.measvalue as numeric),0) not between     productinfo.lowerrange and productinfo.upperrange

Recommended Answers

All 3 Replies

Step through your failed line of code. Echo/print/debug what those values are to see why it may fail.

Member Avatar for Geek-Master

What is the error message from the second statement? Also, double check your data types for productinfo.lowerrange and productinfo.upperrange and make sure they have the same data type, precision and scale numbers.

try with ">=" instead of ">".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.