I have a table that stores different info into a value column as varchar(max)
I need to be able to extract some of the info from this table, convert it to an integer and average the numbers. I’m running into an issue though when trying to convert.
This does not work:
select cast(value as float) as value
from table
Can anyone tell me how to properly convert this?
Presumably, the problem is that some values are not in a numeric format. Try this instead:
This converts all the numbers to float, and puts NULLs in the remaining fields.
If you want to see the values that are causing problems, use this: