SQLTeam.com | Weblogs | Forums

Data Type Varchar() how to do mathematical operation on it


#1

i have a column which is varchar null and how to perform mathematical operations on the varchar column.the problem is its not having int values but decimal values in varchar column.


#2

You can CAST (or CONVERT) it, although if you just include it in a mathematical operation SQL should, implicitly, CAST it.

Much better to use CAST though as it is then obvious to anyone else that you deliberately wanted the datatype changed from VARCHAR to DECIMAL / INT, whereas with an Implicit cast one can never be sure whether it was intentional ... or not!