Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

All new error converting data type varchar to numeric

Status
Not open for further replies.

Danman75

Programmer
Apr 1, 2003
16
US
I have a view using this line of code:

isnull(Sum(Convert(decimal(10,2),credit_balance)),0) as creditamount

Basically, it takes a value that is currently in a varchar type, changes it to a decimal and adds it up. I'm able to run this view with absolutely no problem. However, if I call this view in a second view and use "creditamount" in the SELECT statement, I'm told "Error converting data type varchar to numeric" even though I'm not doing any calculations on it in this second view. I've tried going back to the first view and changing from a convert to a cast statement and I've also tried converting it back to varchar once the data has been summed, but nothing seems to work.

Does anyone know what's going on?
 
Not sure if this would help, but this is how I would set this up:

Sum(Convert(decimal(10,2),isnull(credit_balance,0)) as creditamount
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top