So, I have a table full of information, but every column is a text field. Yeah, I know; move past it.
I need to do math on some of these text fields (Only the ones that actually contain numbers). Specifically, I need to do sum, avg, and count functions. Is there a way to do it?
This is the closest I've gotten so far:
SELECT row_id, [fld0], ahc,
group by row_id, [fld1]
Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
So I tried this:
SELECTrow_id, [fld0], ahc,
[x] = convert(varchar,[fld1])
group by row_id, convert(varchar,[fld1])
Msg 8120, Level 16, State 1, Line 1
Column 'DB.dbo.tbl.fld1' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
Any ideas, short of overhauling the database?