Hi. I have two varchar columns (MAX and MIN) with INT and non-INT characters. Some have leading/trailing spaces. I am trying to do math with only the INT rows using the following query:
But I still get errors like:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'F ' to data type int.
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '8210.8640 ' to data type int.
Is there a way I can pick just the INT rows to run the math against?
Code:
select convert(int, max) - convert(int, min)
from landranges
where (ISNUMERIC(ltrim(rtrim(min)) + 'e0')=1 and ISNUMERIC(ltrim(rtrim(max)) + 'e0')=1)
and convert(int, max) - convert(int, min) > 50
But I still get errors like:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'F ' to data type int.
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '8210.8640 ' to data type int.
Is there a way I can pick just the INT rows to run the math against?