Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 ERROR CONVERTING DATA TYPE VARCHAR TO NUMERIC?

Author  Topic 

Limuh
Yak Posting Veteran

94 Posts

Posted - 2008-03-28 : 02:23:14
im trying to convert this Code from Varchar to Numeric(CAST(ISNULL(del.[Day 60 AMT],0) AS NUMERIC(6,3))+ CAST(ISNULL(del.[Day 90 AMT],0) AS NUMERIC(6,3)) + CAST(ISNULL(del.[Day 120 AMT],0)AS NUMERIC(6,3)) + CAST(ISNULL(del.[Day 150 AMT],0)AS NUMERIC(6,3)) + CAST(ISNULL(del.[Day 180 AMT],0)AS NUMERIC(6,3)) + CAST(ISNULL(del.[Day 210+ AMT],0)AS NUMERIC(6,3))) > 0
i got an error please help.

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-03-28 : 02:25:06
Can you give the error description and the exact query that you are trying to run?
Go to Top of Page

Limuh
Yak Posting Veteran

94 Posts

Posted - 2008-03-28 : 02:27:48
Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.

this is the error message
Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2008-03-28 : 16:26:51
Then you obviously have something in a varchar column that can't be converted to a numeric, just like the error message says.

The solution is easy:

1. Look at the data
2. Find the non-numeric values in the varchar column
3. Fix or delete those rows

Of course, you could have just read the error message yourself and fixed it, without waiting for someone here to post.
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2008-03-28 : 16:43:38
if you do something like

select * from tble where isdigit(ltrim(rtrim(col))) = 0

you will see the problems.
Go to Top of Page
   

- Advertisement -