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 

masond
Constraint Violating Yak Guru

447 Posts

Posted - 2013-11-19 : 04:47:24
Hi all

I have a slight problem with this line of code
sum(Cost) + 'Cost OF calls ' + sum(Cost)/4.85+ 'Num OF calls' as test,
I know the error comes from trying to concatenate a numeric value into a string. It's trying to convert 'Cost OF calls' & 'Num OF calls' into numeric, which isn't going to work.
What would the conversion be ?

Really looking forward to your help

KR

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-11-19 : 05:04:30
you will need to convert from numeric to string before concatenate

convert(varchar(10), sum(Cost)) + 'Cost OF calls ' + convert(varchar(10), sum(Cost)/4.85) + 'Num OF calls' as test,


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -