hi all,
i want to convert char data types to numeric data types.i couldn't do it . error msg is 8114."error converting data type varchar to numeric.
What can i do?
thanks
You can use the IsNumeric function to determine if the value can be converted. IsNumeric returns 1 if the string is numeric or 0 if not.
Example: Select only rows with numeric values.
Select Convert(Integer, ColumnA) As NumericA
From Table
Where IsNumeric(ColumnA) = 1
You can also use the Case function with the IsNumeric function to substitue a value when the column is not numeric or perform the conversion when the column is numeric. Note, I use Cast rather than Convert in this query just to show the syntax. It works the same way.
Select
Case When IsNumeric(ColumnA) = 1
Then Cast(ColumnA As Integer)
Else 0
End As NumericA
From Table Terry L. Broadbent - DBA
Computing Links:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.