In a database I’m working with, I have a field in a table that has a data type of varchar(10). The field can be null and does not have to contain integers, but most of the time it does. I’m comparing the value of this field in my WHERE clause for every iteration in my query to an integer value. At least one number must exist to the right of the decimal place, and there can be up to 2 decimal places, but most of the time there will be 1. 0.00 could qualify if comparing to 0, but 0 would not qualify because it doesn’t have a decimal after it. What is the safest formula to use so that I’m only considering non-null double values?
Suppose I have these values in my table:
NULL
2.49
2.0
2
2.1
2.4
I’d only like these to consider these values as true in this expression:
2.49
2.0
2.1
2.4
Here’s a start.. I haven’t figured in the NULL nor the decimal situation..
AND CONVERT(INT, fieldname.sortorder)=2
Add an additional criteria to do a string comparison.