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?
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?