Question

I need to add a % sign to a calculation I'm doing in MS SQL Server. This is the syntax I am using

Cast(Round(Coalesce(totalsaleamt,0) * 100,0) As Int) + '%'

but I get the error

Conversion failed when converting the varchar value '%' to data type int

What is the proper way to make this concatenation?

Was it helpful?

Solution

Try with something like:

Convert(Varchar(100),Cast(Round(Coalesce(totalsaleamt,0) * 100,0) As Int)) + '%'

That will convert your INT into a varchar and it will then be possible to add the % sign.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top